v.extract - Selects vector objects from an existing vector map and creates a new map containing only the selected objects.
v.extract [-dtr] input=name output=name [type=string[,string,...]] [layer=integer] [new=integer] [list=range] [file=name] [where=sql_query] [--overwrite] [--verbose] [--quiet]
- Dissolve common boundaries (default is no)
- Do not copy table (see also 'new' parameter)
- Reverse selection
- Allow output files to overwrite existing files
- Verbose module output
- Quiet module output
- Name of input vector map
- Name for output vector map
- Types to be extracted
- Options: point,line,boundary,centroid,area,face
- Default: point,line,boundary,centroid,area,face
- Layer number
- If -1, all features in all layers of given type are extracted
- Default: 1
- Enter -1 to keep original categories or the desired NEW category value
- If new >= 0, table is not copied
- Default: -1
- Category values
- Example: 1,3,7-9,13
- Input text file with category numbers/number ranges to be extracted
- If '-' given reads from standard input
- WHERE conditions of SQL statement without 'where' keyword
- Example: income < 1000 and inhab >= 10000
v.extract allows a user to select vector objects from an existing
vector map and creates a new map containing only the selected objects.
Database tables can be queried with SQL statements, if a connection is
Dissolving (optional) is based on the output categories. If 2 adjacent
areas have the same output category, the boundary is removed.
If list, file and where options are not
specified, all features of given type and layer are
extracted. Categories are not changed in that case.
Only features with a category number will be extracted. So if you want to
extract boundaries (which are usually without category, as that information
is normally held in the area's centroid) you must first use
v.category to add them.
Extract areas by category number with dissolving #1:
v.extract -d list=1,2,3,4 input=soils 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.
Extract areas by category number with dissolving #2:
v.extract -d list=1-4 input=soils 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.
Extract all areas and assign the same category to all:
v.extract input=soils 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.
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
Extract vector features which have the given field empty:
v.extract input=forest output=forest_gaps where="CANOPY is NULL"
Extract vector features which have the given field not empty:
v.extract input=forest output=forest_canopy where="CANOPY not NULL"
Reverse extracting (behaves like selective vector objects deleting):
Remove unreferenced stations from the GlobalSOD database:
# check what to delete:
v.db.select gsod_stationlist where="latitude < -91"
# perform reverse selection
v.extract -r gsod_stationlist out=gsod_stationlist_clean where="latitude < -91"
Dissolving based on column attributes:
# check column names:
v.info -c polbnda_italy
# reclass based on desired column:
v.reclass polbnda_italy out=polbnda_italy_recl_nam col=vmap_nam
v.info -c polbnda_italy_recl_nam
v.extract -d polbnda_italy_recl_nam out=pol_italy_regions
produces a new vector map with common boundaries dissolved where the reclassed
attributes of adjacent (left/right) areas are identical.
Remove islands from polygon map
v.extract in=map_with_islands out=maps_without_islands list=1-99999
v.extract -d in=map_with_islands out=maps_without_islands
GRASS SQL interface
R.L. Glenn, USDA, SCS, NHQ-CGIS
GRASS 6 port by Radim Blazek
Last changed: $Date: 2008-02-02 05:33:41 -0800 (Sat, 02 Feb 2008) $
Main index - vector index - Full index
© 2003-2008 GRASS Development Team