.TH v.select 1grass "" "GRASS 7.8.5" "GRASS GIS User's Manual" .SH NAME \fI\fBv.select\fR\fR \- Selects features from vector map (A) by features from other vector map (B). .SH KEYWORDS vector, geometry, spatial query .SH SYNOPSIS \fBv.select\fR .br \fBv.select \-\-help\fR .br \fBv.select\fR [\-\fBtcr\fR] \fBainput\fR=\fIname\fR [\fBalayer\fR=\fIstring\fR] [\fBatype\fR=\fIstring\fR[,\fIstring\fR,...]] \fBbinput\fR=\fIname\fR [\fBblayer\fR=\fIstring\fR] [\fBbtype\fR=\fIstring\fR[,\fIstring\fR,...]] \fBoutput\fR=\fIname\fR \fBoperator\fR=\fIstring\fR [\fBrelate\fR=\fIstring\fR] [\-\-\fBoverwrite\fR] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-t\fR" 4m .br Do not create attribute table .IP "\fB\-c\fR" 4m .br Do not skip features without category .IP "\fB\-r\fR" 4m .br Reverse selection .IP "\fB\-\-overwrite\fR" 4m .br Allow output files to overwrite existing files .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBainput\fR=\fIname\fR \fB[required]\fR" 4m .br Name of input vector map .br Input vector map from which to select features (A) .IP "\fBalayer\fR=\fIstring\fR" 4m .br Layer number (vector map A) .br Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. .br Default: \fI1\fR .IP "\fBatype\fR=\fIstring[,\fIstring\fR,...]\fR" 4m .br Feature type (vector map A) .br Input feature type .br Options: \fIpoint, line, boundary, centroid, area\fR .br Default: \fIpoint,line,area\fR .IP "\fBbinput\fR=\fIname\fR \fB[required]\fR" 4m .br Name of input vector map .br Query vector map (B) .IP "\fBblayer\fR=\fIstring\fR" 4m .br Layer number (vector map B) .br Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. .br Default: \fI1\fR .IP "\fBbtype\fR=\fIstring[,\fIstring\fR,...]\fR" 4m .br Feature type (vector map B) .br Input feature type .br Options: \fIpoint, line, boundary, centroid, area\fR .br Default: \fIpoint,line,area\fR .IP "\fBoutput\fR=\fIname\fR \fB[required]\fR" 4m .br Name for output vector map .IP "\fBoperator\fR=\fIstring\fR \fB[required]\fR" 4m .br Operator defines required relation between features .br A feature is written to output if the result of operation \(cqainput operator binput\(cq is true. An input feature is considered to be true, if category of given layer is defined. .br Options: \fIoverlap, equals, disjoint, intersects, touches, crosses, within, contains, overlaps, relate\fR .br Default: \fIoverlap\fR .br \fBoverlap\fR: features partially or completely overlap .br \fBequals\fR: features are spatially equals (using GEOS) .br \fBdisjoint\fR: features do not spatially intersect (using GEOS) .br \fBintersects\fR: features spatially intersect (using GEOS) .br \fBtouches\fR: features spatially touches (using GEOS) .br \fBcrosses\fR: features spatially crosses (using GEOS) .br \fBwithin\fR: feature A is completely inside feature B (using GEOS) .br \fBcontains\fR: feature B is completely inside feature A (using GEOS) .br \fBoverlaps\fR: features spatially overlap (using GEOS) .br \fBrelate\fR: feature A is spatially related to feature B (using GEOS, requires \(cqrelate\(cq option) .IP "\fBrelate\fR=\fIstring\fR" 4m .br Intersection Matrix Pattern used for \(cqrelate\(cq operator .SH DESCRIPTION \fIv.select\fR allows the user to select features from a vector map by features from another one. .PP Supported operators (without GEOS; using GRASS\(cq own algorithm): .RS 4n .IP \(bu 4n \fBoverlap\fR \- features partially or completely overlap (GEOS equivalent: intersects) .RE Supported operators (internally using GEOS \- Geometry Engine, Open Source): .RS 4n .IP \(bu 4n \fBequals\fR \- features are spatially equals .IP \(bu 4n \fBdisjoint\fR \- features do not spatially intersect .IP \(bu 4n \fBintersects\fR \- features spatially intersect (equivalent to native \(cqoverlap\(cq) .IP \(bu 4n \fBtouches\fR \- features spatially touches .IP \(bu 4n \fBcrosses\fR \- features spatially crosses .IP \(bu 4n \fBwithin\fR \- feature A is completely inside feature B .IP \(bu 4n \fBcontains\fR \- feature B is completely inside feature A .IP \(bu 4n \fBoverlaps\fR \- features spatially overlap .IP \(bu 4n \fBrelate\fR \- feature A is spatially related to feature B .RE .SH NOTES Only features with category numbers will be considered. If required the \fIv.category\fR module can be used to add them. Typically boundaries do not need to be given a category number, as an area\(cqs attributes are inherited from the centroid. Typically points, lines, and centroids will always want to have a cat number. E.g. take a road which separates two farms. It is ambiguous as to which farm an attribute that is attached to the road belongs to. The boundary only needs a cat number if it will hold its own attributes, such as road name or pavement form. A centroid in each paddock holds the information with respect to ownership, area, etc. .SH EXAMPLES Preparation of example data (North Carolina sample dataset): .br .nf \fC # Create an grid for overlaying to ZIP code vector map v.mkgrid map=boxgrid grid=10,10 position=coor \(rs coordinates=583600,201500 box=5000,5000 # set region to ZIP codes and boxgrid vector maps g.region vector=zipcodes_wake,boxgrid \-p res=100 \-a # enlarge region a bit for \(dqwhite border\(dq around map in monitor g.region n=n+1000 s=s\-1000 w=w\-1000 e=e+1000 \-p d.mon wx0 \fR .fi .SS OVERLAP: features partially or completely overlap (using GRASS) Select grid boxes (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=boxgrid fill_color=85:130:176 v.select ainput=boxgrid binput=zipcodes_wake output=v_select_OVERLAP operator=overlap d.vect map=v_select_OVERLAP d.vect map=zipcodes_wake type=boundary color=255:255:50 \fR .fi .br v.select with OVERLAP operator: selected grid boxes shown in yellow (using GRASS method) .SS OVERLAPS features spatially overlap (using GEOS) Select grid boxes (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=boxgrid fill_color=85:130:176 v.select ainput=boxgrid binput=zipcodes_wake output=v_select_OVERLAPS operator=overlaps d.vect map=v_select_OVERLAPS d.vect map=zipcodes_wake type=boundary color=255:255:50 \fR .fi .br v.select with OVERLAPS operator: selected grid boxes shown in yellow (using GEOS method) .SS DISJOINT: features do not spatially intersect (using GEOS) Select grid boxes (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=boxgrid fill_color=85:130:176 v.select ainput=boxgrid binput=zipcodes_wake output=v_select_DISJOINT operator=disjoint d.vect map=v_select_DISJOINT d.vect map=zipcodes_wake type=boundary color=255:255:50 \fR .fi .br v.select with DISJOINT operator: selected grid boxes shown in yellow .SS EQUALS: features are spatially equals (using GEOS) Select zipcode polygon (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 v.extract input=zipcodes_wake where=ZIPCODE_ID=35 output=zipcodeID35 v.select ainput=zipcodes_wake binput=zipcodeID35 output=v_select_EQUALS operator=equals d.vect map=v_select_EQUALS d.vect map=zipcodes_wake type=boundary color=255:255:50 \fR .fi .br v.select with EQUALS operator: selected grid boxes shown in yellow .SS INTERSECTS: features spatially intersect (using GEOS) Select zipcode polygons (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=boxgrid fill_color=85:130:176 v.select ainput=zipcodes_wake binput=boxgrid output=v_select_INTERSECTS operator=intersects d.vect map=v_select_INTERSECTS d.vect map=boxgrid type=boundary color=255:255:50 \fR .fi .br v.select with INTERSECTS operator: selected grid boxes shown in yellow .SS TOUCHES: features spatially touches (using GEOS) Select polygons (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=zipcodeID35 fill_color=85:130:176 v.select ainput=zipcodes_wake binput=zipcodeID35 output=v_select_TOUCHES operator=touches d.vect map=v_select_TOUCHES d.vect map=zipcodes_wake type=boundary color=255:255:50 \fR .fi .br v.select with TOUCHES operator: selected polygons shown in yellow (blue: input polygon) .SS CROSSES: features spatially crosses (using GEOS) Select zipcode polygons by lines (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=busroute1 color=200:27:27 width=3 v.select ainput=zipcodes_wake binput=busroute1 output=v_select_CROSSES operator=crosses d.vect map=v_select_CROSSES d.vect map=zipcodes_wake type=boundary color=255:255:50 d.vect map=busroute1 color=200:27:27 width=3 \fR .fi .br v.select with CROSSES operator: selected polygons shown in yellow (red: input lines) .SS WITHIN feature A is completely inside feature B (using GEOS) Select zipcode polygons (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=boundary_county fill_color=85:130:176 v.select ainput=zipcodes_wake binput=boundary_county output=v_select_WITHIN operator=within d.vect map=v_select_WITHIN \fR .fi .br v.select with WITHIN operator: selected polygons shown in yellow (blue: input polygons) .SS CONTAINS feature B is completely inside feature A (using GEOS) Select zipcode polygon (North Carolina sample dataset): .SS CONTAINS with polygons .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=zipcodeID35 fill_color=85:130:176 v.select ainput=zipcodes_wake binput=zipcodeID35 \(rs output=v_select_CONTAINS_pol operator=contains d.vect map=v_select_CONTAINS \fR .fi .br v.select with CONTAINS operator: selected polygon shown in yellow (blue: input polygon, not visible) .SS CONTAINS with points .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=hospitals fill_color=195:31:31 icon=basic/cross3 size=10 v.select ainput=zipcodes_wake binput=hospitals \(rs output=v_select_CONTAINS_pnts operator=contains d.vect map=v_select_CONTAINS_pnts d.vect map=hospitals fill_color=195:31:31 icon=basic/cross3 size=10 \fR .fi .br v.select with CONTAINS operator: selected polygons shown in yellow (red: input points) .SS RELATE feature A is spatially related to feature B (using GEOS) This operator additionally requires the \fBrelate\fR parameter (in other GIS called \(cqST_Relate\(cq). This operator allows calculating the Dimensionally Extended nine\-Intersection Model (DE\-9IM). In the following one example: Select polygon with \(cqTOUCHES\(cq operator (North Carolina sample dataset): .br .nf \fC d.vect map=zipcodes_wake fill_color=0:128:0 d.vect map=zipcodeID35 fill_color=85:130:176 v.select ainput=zipcodeID35 binput=zipcodes_wake \(rs output=v_select_TOUCHES_relate operator=relate relate=\(cqT********\(cq d.vect map=v_select_TOUCHES \fR .fi The result of relate=\(cqT********\(cq is the same as seen above in the example \(cqTOUCHES\(cq. See the DE\-9IM page for related operators and their definition. .SS Extraction of points falling into a polygon Extract fire stations (points) falling into urban area (polygon) \- North Carolina data set (point in polygon test): .br .nf \fC v.select ainput=firestations binput=urbanarea output=urban_firestations \(rs operator=overlap \fR .fi .SS Extraction of lines overlapping with a polygon Extract railroad lines from zip code map overlapping with the urban area (line in polygon test): .br .nf \fC v.select ainput=railroads binput=urbanarea \(rs output=railroads_in_urbanarea operator=overlap \fR .fi .SS Extraction of areas overlapping with a line Extract those areas from zip code map which overlap with railroads (polygon on line test): .br .nf \fC # first add a tiny buffer around railroad lines: v.buffer input=railroads output=railroads_buf20m \(rs distance=20 v.select ainput=zipcodes_wake binput=railroads_buf20m \(rs output=zipcodes_wake_railroads operator=overlap \fR .fi .SH SEE ALSO \fI v.category, v.clip, v.overlay, v.extract \fR .PP GRASS SQL interface .br GEOS \- Geometry Engine, Open Source .SH AUTHORS Radim Blazek .br GEOS support by Martin Landa, Czech Technical University in Prague, Czech Republic .br ZIP code examples by Carol X. Garzon\-Lopez, Trento, Italy .SH SOURCE CODE .PP Available at: v.select source code (history) .PP Main index | Vector index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual