v.extract(1)

πŸ’… v.extract(1) β€” GRASS GIS User's Manual πŸ’…

okay bestie, sit down, hydrate, because this is the page for v.extract and it's genuinely iconic. It's a GRASS GIS manual page (yes, the one for v.extract(1)), and it's about grabbing the vector features you want out of a map and yeeting them into a brand new map. only the chosen ones make it. πŸŽ€


✨ NAME ✨

v.extract β€” selects vector features from an existing vector map and creates a new vector map containing only the selected features. no strays, no extras. it's giving curated. πŸ¦‹


πŸ”‘ KEYWORDS πŸ”‘

vector, extract, select, dissolve, random


🌸 SYNOPSIS 🌸

v.extract
v.extract --help
v.extract [-dtr] input=name  [layer=string]   [type=string[,string,...]]
[cats=range]   [where=sql_query]  output=name  [file=name]
[random=integer]   [new=integer]   [dissolve_column=name]
[--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]

🚩 Flags

  • -d β€” dissolve common boundaries (default is no)
  • -t β€” do not copy attributes (peep the new parameter too, iykyk)
  • -r β€” reverse selection πŸ”„
  • --overwrite β€” allow output files to overwrite existing files (chaotic but fine)
  • --help β€” print usage summary
  • --verbose β€” verbose module output (she's chatty)
  • --quiet β€” quiet module output (she's mysterious)
  • --ui β€” force launching GUI dialog

πŸŽ€ Parameters

  • input=name [required] β€” name of input vector map. or, plot twist, a data source for direct OGR access.
  • layer=string β€” layer number or name ('-1' for all layers). a single vector map can be connected to multiple database tables, and this number determines which table to use. when used with direct OGR access this is the layer name. default: 1.
  • type=string[,string,...] β€” types to be extracted. this is the input feature type. options: point, line, boundary, centroid, area, face. default: point,line,boundary,centroid,area,face (yes, all of them, she's generous πŸ’–).
  • cats=range β€” category values. example: 1,3,7-9,13.
  • where=sql_query β€” WHERE conditions of SQL statement without 'where' keyword. example: income < 1000 and population >= 10000.
  • output=name [required] β€” name for output vector map. the glow-up destination. ✨
  • file=name β€” input text file with category numbers/number ranges to be extracted. if '-' given, reads from standard input.
  • random=integer β€” number of random categories matching vector objects to extract. number must be smaller than unique cat count in layer. ⚠️
  • new=integer β€” desired new category value (enter -1 to keep original categories). if new >= 0, attributes is not copied. default: -1.
  • dissolve_column=name β€” name of attribute column for dissolving areas. preserves category values.

πŸ’– DESCRIPTION πŸ’–

v.extract allows a user to select vector objects from an existing vector map and creates a new map containing only the selected objects. basically: you point at stuff, she keeps it, everything else is not invited to the party. 🫢

database tables can be queried with SQL statements, if a connection is established. dissolving (optional) is based on the output categories β€” and the way that works is, if 2 adjacent areas have the same output category, the boundary is removed. gone. deleted. no boundary between besties. πŸ’…

if cats, file, random or where options are not specified, all features of given type and layer are extracted. categories are not changed in that case. (yes, everything, she's not picky today.)


πŸ“Œ NOTES πŸ“Œ

only features with a category number in the selected layer will be extracted. so if you want to extract boundaries β€” which are usually without category, since that information is normally held in the area's centroid β€” you must first use v.category to add them, or use layer=-1. no cap, this trips people up every single time. 😭

🌈 EXAMPLES 🌈

these examples are intended for the North Carolina sample dataset. let's get into it.

πŸ“ Extract areas by category number with dissolving #1

v.extract -d cats=1,2,3,4 input=soils_wake output=soil_groupa type=area new=0

produces a new vector soil_groupa, containing those areas from vector soils which have category numbers 1 thru 4; any common boundaries are dissolved, and all areas in the new map will be assigned category number 0. slay. ✨

πŸ“ Extract areas by category number with dissolving #2

v.extract -d cats=1-4 input=soils_wake output=soil_groupa type=area new=-1

produces a new vector map soil_groupa containing the areas from vector soils which have categories 1 thru 4. any common boundaries are dissolved, all areas in the new map will retain their original category numbers 1 thru 4, since new was set to -1. iconic behaviour, honestly. πŸ‘‘

πŸ“ Extract all areas and assign the same category to all

v.extract input=soils_wake output=soil_groupa type=area new=1

produces a new vector map soil_groupa containing all areas from soils. no common boundaries are dissolved, all areas of the new map will be assigned category number 1. everyone matching, matching, yes. πŸŽ€

πŸ“ Extract vectors with SQL

v.extract input=markveggy.shp output=markveggy.1 new=13 \
  where="(VEGTYPE = ’Wi’) or (VEGTYPE = ’PS’) or (PRIME_TYPE=’Wi’)"

produces a new vector map with category number 13 if the SQL statement is fulfilled.

πŸ“ Extract vector features which have the given field empty

v.extract input=lakes output=lakes_gaps where="FTYPE is NULL"

πŸ“ Extract vector features which have the given field not empty

v.extract input=lakes output=lakes_ftype where="FTYPE not NULL"

πŸ“ Reverse extracting (behaves like selective vector objects deleting)

remove meteorological stations from map which are located above 1000m:

# check what to delete:
v.db.select precip_30ynormals where="elev > 1000"
# perform reverse selection
v.extract -r input=precip_30ynormals output=precip_30ynormals_lowland \
  where="elev > 1000"
# verify
v.db.select precip_30ynormals_lowland

πŸ“ Dissolving based on column attributes

# check column names:
v.info -c zipcodes_wake
# reclass based on desired column:
v.reclass input=zipcodes_wake output=zipcodes_wake_recl_nam column=ZIPNAME
# verify:
v.info -c zipcodes_wake_recl_nam
v.db.select zipcodes_wake_recl_nam
# dissolve:
v.extract -d input=zipcodes_wake_recl_nam output=zipcodes_wake_regions

this produces a new vector map with common boundaries dissolved where the reclassed attributes of adjacent (left/right) areas are identical. πŸ’œ

πŸ“ Extract 3 random areas from geology map

v.extract input=geology output=random_geology type=area random=3

this creates a new map with three random categories matching areas. note that there may be more than one feature with the same category. πŸ™ˆ


πŸ‘€ SEE ALSO πŸ‘€

v.category, v.dissolve, v.reclass, GRASS SQL interface


🫢 AUTHORS 🫢

  • R.L. Glenn, USDA, SCS, NHQ-CGIS
  • GRASS 6 port by Radim Blazek

πŸ’» SOURCE CODE πŸ’»

available at: v.extract source code (history)

accessed: Saturday Jan 17 05:41:21 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. this was GRASS 8.4.2's v.extract(1), straight from the GRASS GIS User's Manual, and if you made it all the way down here you are lowkey a legend. go extract something cute. πŸ’–βœ¨πŸ¦‹

πŸ“¦ where this page comes from