v.select(1)

v.select πŸ’–βœ¨

okay bestie, so this is the GRASS GIS User's Manual page for v.select(1) and honestly? it's giving spatial-query main character energy and i'm obsessed. it does one iconic thing: it picks features out of one vector map by looking at features in another vector map. that's it. that's the whole vibe. πŸ¦‹


✨ NAME ✨

v.select β€” selects features from vector map (A) by features from other vector map (B). literally a matchmaking service but for geometry πŸ’…


🌸 KEYWORDS 🌸

vector, geometry, spatial query β€” iykyk πŸŽ€


🧚 SYNOPSIS 🧚

v.select
v.select --help
v.select [-tcr] ainput=name  [alayer=string]
[atype=string[,string,...]]  binput=name  [blayer=string]
[btype=string[,string,...]]  output=name operator=string
[relate=string]   [--overwrite]  [--help]  [--verbose]  [--quiet]
[--ui]

πŸ‘‘ Flags

  • -t β€” do not create attribute table. no table, no problem, we're keeping it light ✨
  • -c β€” do not skip features without category. normally the cat-less ones get ghosted, but this says nah, keep them 🫢
  • -r β€” reverse selection. plot twist, we're flipping the whole thing πŸ”„
  • --overwrite β€” allow output files to overwrite existing files. yes, we're bulldozing the old one, no cap πŸ’€
  • --help β€” print usage summary. your lil cheat sheet πŸŽ€
  • --verbose β€” verbose module output. it will yap. lovingly. 😭
  • --quiet β€” quiet module output. shhh era 🀫
  • --ui β€” force launching GUI dialog. for the girlies who like buttons 🌈

πŸ“ Parameters

  • ainput=name [required] β€” name of input vector map. this is the input vector map from which to select features (A), aka the one we're picking from πŸ’–
  • alayer=string β€” layer number (vector map A). so here's the tea: vector features can have category values in different layers, and this number determines which layer to use. when used with direct OGR access this is the layer name. default: 1 ✨
  • atype=string[,string,...] β€” feature type (vector map A), a.k.a. input feature type. options: point, line, boundary, centroid, area. default: point,line,area 🌸
  • binput=name [required] β€” name of input vector map. this is the query vector map (B), the one doing the asking πŸ’…
  • blayer=string β€” layer number (vector map B). same deal as alayer: vector features can have category values in different layers, this number determines which layer to use, and with direct OGR access this is the layer name. default: 1 πŸ¦‹
  • btype=string[,string,...] β€” feature type (vector map B), a.k.a. input feature type. options: point, line, boundary, centroid, area. default: point,line,area ⭐
  • output=name [required] β€” name for output vector map. the glow-up destination πŸ‘‘
  • operator=string [required] β€” the operator defines the required relation between features. here's how it works fr fr: a feature is written to output if the result of operation 'ainput operator binput' is true. and an input feature is considered to be true if category of given layer is defined. options: overlap, equals, disjoint, intersects, touches, crosses, within, contains, overlaps, relate. default: overlap
    • overlap: features partially or completely overlap
    • equals: features are spatially equals (using GEOS)
    • disjoint: features do not spatially intersect (using GEOS)
    • intersects: features spatially intersect (using GEOS)
    • touches: features spatially touches (using GEOS)
    • crosses: features spatially crosses (using GEOS)
    • within: feature A is completely inside feature B (using GEOS)
    • contains: feature B is completely inside feature A (using GEOS)
    • overlaps: features spatially overlap (using GEOS)
    • relate: feature A is spatially related to feature B (using GEOS, requires 'relate' option)
  • relate=string β€” intersection matrix pattern used for 'relate' operator. yes it's a whole vibe, don't worry about it unless you picked relate πŸ’œ

πŸ’– DESCRIPTION πŸ’–

v.select lets you select features from a vector map by features from another one. iconic. no notes. πŸŽ€

supported operators (without GEOS; using GRASS' own algorithm):

  • overlap β€” features partially or completely overlap (GEOS equivalent: intersects)

supported operators (internally using GEOS β€” Geometry Engine, Open Source):

  • equals β€” features are spatially equals
  • disjoint β€” features do not spatially intersect
  • intersects β€” features spatially intersect (equivalent to native 'overlap')
  • touches β€” features spatially touches
  • crosses β€” features spatially crosses
  • within β€” feature A is completely inside feature B
  • contains β€” feature B is completely inside feature A
  • overlaps β€” features spatially overlap
  • relate β€” feature A is spatially related to feature B

🌈 NOTES 🌈

bestie listen up, this part matters πŸ’…

only features with category numbers will be considered. if you need them, the v.category module can be used to add them. 🫢

typically boundaries do not need to be given a category number, because an area's 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. πŸ„βœ¨


okay that's part one, there's more coming so don't go anywhere bestie πŸ’œ

✨ EXAMPLES ✨

Okay bestie, this is the fun part β€” real commands, real vibes, and literally every single one of them is here πŸ’–

🌸 Preparation of example data (North Carolina sample dataset)

First we gotta make the data, no cap:

# Create an grid for overlaying to ZIP code vector map
v.mkgrid map=boxgrid grid=10,10 position=coor \
         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 "white border" around map in monitor
g.region n=n+1000 s=s-1000 w=w-1000 e=e+1000 -p
d.mon wx0

πŸŽ€ OVERLAP: features partially or completely overlap (using GRASS)

Select grid boxes (North Carolina sample dataset) β€” the GRASS-method way, periodt:

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

v.select with OVERLAP operator: selected grid boxes shown in yellow (using GRASS method)


🌈 OVERLAPS features spatially overlap (using GEOS)

Select grid boxes (North Carolina sample dataset) β€” this time it's GEOS doing the work:

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

v.select with OVERLAPS operator: selected grid boxes shown in yellow (using GEOS method)


πŸ’œ DISJOINT: features do not spatially intersect (using GEOS)

The ones that are not touching each other at all, we love a no-contact queen:

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

v.select with DISJOINT operator: selected grid boxes shown in yellow


πŸ¦‹ EQUALS: features are spatially equals (using GEOS)

Select zipcode polygon (North Carolina sample dataset) β€” same shape, same energy:

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

v.select with EQUALS operator: selected grid boxes shown in yellow


✨ INTERSECTS: features spatially intersect (using GEOS)

Select zipcode polygons (North Carolina sample dataset) β€” they overlap somewhere, anywhere:

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

v.select with INTERSECTS operator: selected grid boxes shown in yellow


πŸ“ TOUCHES: features spatially touches (using GEOS)

Select polygons (North Carolina sample dataset) β€” adjacent besties, sharing that boundary 🫢:

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

v.select with TOUCHES operator: selected polygons shown in yellow (blue: input polygon)


πŸ”₯ CROSSES: features spatially crosses (using GEOS)

Select zipcode polygons by lines (North Carolina sample dataset) β€” the line literally cuts through:

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

v.select with CROSSES operator: selected polygons shown in yellow (red: input lines)


πŸ‘‘ WITHIN feature A is completely inside feature B (using GEOS)

Select zipcode polygons (North Carolina sample dataset) β€” fully tucked in, cozy:

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

v.select with WITHIN operator: selected polygons shown in yellow (blue: input polygons)


πŸ’– CONTAINS feature B is completely inside feature A (using GEOS)

Select zipcode polygon (North Carolina sample dataset):

🧚 CONTAINS with polygons

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_CONTAINS_pol operator=contains
d.vect map=v_select_CONTAINS

v.select with CONTAINS operator: selected polygon shown in yellow (blue: input polygon, not visible)

🧚 CONTAINS with points

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 \
         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

v.select with CONTAINS operator: selected polygons shown in yellow (red: input points)


Okay so this one is extra β€” this operator additionally requires the relate parameter (in other GIS called 'ST_Relate'). This operator allows calculating the Dimensionally Extended nine-Intersection Model (DE-9IM). In the following one example: Select polygon with 'TOUCHES' operator (North Carolina sample dataset):

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 \
         output=v_select_TOUCHES_relate operator=relate relate=’T********’
d.vect map=v_select_TOUCHES

The result of relate=’T********’ is the same as seen above in the example 'TOUCHES'. See the DE-9IM page for related operators and their definition.


🌟 Extraction of points falling into a polygon

Extract fire stations (points) falling into urban area (polygon) - North Carolina data set (point in polygon test):

v.select ainput=firestations binput=urbanarea output=urban_firestations \
         operator=overlap

🌟 Extraction of lines overlapping with a polygon

Extract railroad lines from zip code map overlapping with the urban area (line in polygon test):

v.select ainput=railroads binput=urbanarea \
         output=railroads_in_urbanarea operator=overlap

🌟 Extraction of areas overlapping with a line

Extract those areas from zip code map which overlap with railroads (polygon on line test):

# first add a tiny buffer around railroad lines:
v.buffer input=railroads output=railroads_buf20m \
  distance=20
v.select ainput=zipcodes_wake binput=railroads_buf20m \
  output=zipcodes_wake_railroads operator=overlap

πŸ’… SEE ALSO

  • v.category
  • v.clip
  • v.overlay
  • v.extract

GRASS SQL interface

GEOS - Geometry Engine, Open Source


🫢 AUTHORS

  • Radim Blazek
  • GEOS support by Martin Landa, Czech Technical University in Prague, Czech Republic
  • ZIP code examples by Carol X. Garzon-Lopez, Trento, Italy

πŸŽ€ SOURCE CODE

Available at: v.select source code (history)

Accessed: Saturday Jan 17 05:41:31 2026

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

Β© 2003-2025 GRASS Development Team, GRASS GIS 8.4.2 Reference Manual


And that's the whole page, bestie!! πŸ’– You just read the GRASS GIS 8.4.2 reference manual entry for v.select(1), accessed on Saturday Jan 17 05:41:31 2026. Go select some vectors, you absolute icon πŸ‘‘βœ¨

πŸ“¦ where this page comes from