3
<em>v.extract</em> allows a user to select vector objects from an existing
4
vector map and creates a new map containing only the selected objects.
5
Database tables can be queried with SQL statements, if a connection is
7
Dissolving (optional) is based on the output categories. If 2 adjacent
8
areas have the same output category, the boundary is removed.
11
If <b>cats</b>, <b>file</b>, <b>random</b> or <b>where</b> options are not
12
specified, all features of given type and layer are
13
extracted. Categories are not changed in that case.
17
Only features with a category number will be extracted. So if you want to
18
extract boundaries (which are usually without category, as that information
19
is normally held in the area's centroid) you must first use
20
<em><a href="v.category.html">v.category</a></em> to add them.
24
The examples are intended for the North Carolina sample dataset:
26
<h3>Extract areas by category number with dissolving #1:</h3>
27
<div class="code"><pre>
28
v.extract -d cats=1,2,3,4 input=soils_wake output=soil_groupa type=area new=0
32
produces a new vector <b>soil_groupa</b>, containing those areas from vector
33
<b>soils</b> which have category numbers <b>1 thru 4</b>; any common boundaries are
34
dissolved, and all areas in the new map will be assigned category number 0.
36
<h3>Extract areas by category number with dissolving #2:</h3>
37
<div class="code"><pre>
38
v.extract -d cats=1-4 input=soils_wake output=soil_groupa type=area new=-1
41
produces a new vector map <b>soil_groupa</b> containing the areas from vector
42
<b>soils</b> which have categories <b>1 thru 4</b>. Any common boundaries are
43
dissolved, all areas in the new map will retain their original category
44
numbers 1 thru 4, since <b>new</b> was set to -1.
46
<h3>Extract all areas and assign the same category to all:</h3>
47
<div class="code"><pre>
48
v.extract input=soils_wake output=soil_groupa type=area new=1
51
produces a new vector map <b>soil_groupa</b> containing all areas from
52
<b>soils</b>. No common boundaries are dissolved, all areas of the new
53
map will be assigned category number 1.
55
<h3>Extract vectors with SQL:</h3>
56
<div class="code"><pre>
57
v.extract input=markveggy.shp output=markveggy.1 new=13 \
58
where="(VEGTYPE = 'Wi') or (VEGTYPE = 'PS') or (PRIME_TYPE='Wi')"
61
produces a new vector map with category number 13 if the SQL statement is
64
<h3>Extract vector features which have the given field empty:</h3>
65
<div class="code"><pre>
66
v.extract input=lakes output=lakes_gaps where="FTYPE is NULL"
69
<h3>Extract vector features which have the given field not empty:</h3>
70
<div class="code"><pre>
71
v.extract input=lakes output=lakes_ftype where="FTYPE not NULL"
74
<h3>Reverse extracting (behaves like selective vector objects deleting):</h3>
76
Remove meteorological stations from map which are located above 1000m:
77
<div class="code"><pre>
78
# check what to delete:
79
v.db.select precip_30ynormals where="elev > 1000"
81
# perform reverse selection
82
v.extract -r input=precip_30ynormals output=precip_30ynormals_lowland \
83
where="elev > 1000"
86
v.db.select precip_30ynormals_lowland
90
<h3>Dissolving based on column attributes:</h3>
91
<div class="code"><pre>
93
v.info -c zipcodes_wake
95
# reclass based on desired column:
96
v.reclass input=zipcodes_wake output=zipcodes_wake_recl_nam column=ZIPNAME
99
v.info -c zipcodes_wake_recl_nam
100
v.db.select zipcodes_wake_recl_nam
103
v.extract -d input=zipcodes_wake_recl_nam output=zipcodes_wake_regions
106
This produces a new vector map with common boundaries dissolved where the reclassed
107
attributes of adjacent (left/right) areas are identical.
109
<h3>Remove islands from polygon map</h3>
110
<div class="code"><pre>
111
v.extract input=map_with_islands output=maps_without_islands cats=1-99999
113
v.extract -d in=map_with_islands out=maps_without_islands
116
<h3>Extract 3 random areas from geology map</h3>
118
<div class="code"><pre>
119
v.extract input=geology output=random_geology type=area random=3
121
This creates a new map with three random categories matching areas.
122
Note that there may be more than one feature with the same category.
127
<a href="v.category.html">v.category</a>,
128
<a href="v.dissolve.html">v.dissolve</a>,
129
<a href="v.reclass.html">v.reclass</a>,
130
<a href="sql.html">GRASS SQL interface</a>
135
R.L. Glenn, USDA, SCS, NHQ-CGIS<br>
136
GRASS 6 port by Radim Blazek
138
<p><i>Last changed: $Date: 2013-12-27 17:53:51 +0100 (Fri, 27 Dec 2013) $</i>