1v.extract(1) Grass User's Manual v.extract(1)
2
3
4
6 v.extract - Selects vector features from an existing vector map and
7 creates a new vector map containing only the selected features.
8
10 vector, extract, select, dissolve, random
11
13 v.extract
14 v.extract --help
15 v.extract [-dtr] input=name [layer=string]
16 [type=string[,string,...]] [cats=range] [where=sql_query] out‐
17 put=name [file=name] [random=integer] [new=integer] [--over‐
18 write] [--help] [--verbose] [--quiet] [--ui]
19
20 Flags:
21 -d
22 Dissolve common boundaries (default is no)
23
24 -t
25 Do not copy attributes (see also ’new’ parameter)
26
27 -r
28 Reverse selection
29
30 --overwrite
31 Allow output files to overwrite existing files
32
33 --help
34 Print usage summary
35
36 --verbose
37 Verbose module output
38
39 --quiet
40 Quiet module output
41
42 --ui
43 Force launching GUI dialog
44
45 Parameters:
46 input=name [required]
47 Name of input vector map
48 Or data source for direct OGR access
49
50 layer=string
51 Layer number or name
52 Vector features can have category values in different layers. This
53 number determines which layer to use. When used with direct OGR
54 access this is the layer name.
55 Default: 1
56
57 type=string[,string,...]
58 Types to be extracted
59 Input feature type
60 Options: point, line, boundary, centroid, area, face
61 Default: point,line,boundary,centroid,area,face
62
63 cats=range
64 Category values
65 Example: 1,3,7-9,13
66
67 where=sql_query
68 WHERE conditions of SQL statement without ’where’ keyword
69 Example: income < 1000 and population >= 10000
70
71 output=name [required]
72 Name for output vector map
73
74 file=name
75 Input text file with category numbers/number ranges to be extracted
76 If ’-’ given reads from standard input
77
78 random=integer
79 Number of random categories matching vector objects to extract
80 Number must be smaller than unique cat count in layer
81
82 new=integer
83 Desired new category value (enter -1 to keep original categories)
84 If new >= 0, attributes is not copied
85 Default: -1
86
88 v.extract allows a user to select vector objects from an existing vec‐
89 tor map and creates a new map containing only the selected objects.
90 Database tables can be queried with SQL statements, if a connection is
91 established. Dissolving (optional) is based on the output categories.
92 If 2 adjacent areas have the same output category, the boundary is
93 removed.
94
95 If cats, file, random or where options are not specified, all features
96 of given type and layer are extracted. Categories are not changed in
97 that case.
98
100 Only features with a category number will be extracted. So if you want
101 to extract boundaries (which are usually without category, as that
102 information is normally held in the area’s centroid) you must first use
103 v.category to add them.
104
106 The examples are intended for the North Carolina sample dataset:
107
108 Extract areas by category number with dissolving #1:
109 v.extract -d cats=1,2,3,4 input=soils_wake output=soil_groupa type=area new=0
110
111 produces a new vector soil_groupa, containing those areas from vector
112 soils which have category numbers 1 thru 4; any common boundaries are
113 dissolved, and all areas in the new map will be assigned category num‐
114 ber 0.
115
116 Extract areas by category number with dissolving #2:
117 v.extract -d cats=1-4 input=soils_wake output=soil_groupa type=area new=-1
118
119 produces a new vector map soil_groupa containing the areas from vector
120 soils which have categories 1 thru 4. Any common boundaries are dis‐
121 solved, all areas in the new map will retain their original category
122 numbers 1 thru 4, since new was set to -1.
123
124 Extract all areas and assign the same category to all:
125 v.extract input=soils_wake output=soil_groupa type=area new=1
126
127 produces a new vector map soil_groupa containing all areas from soils.
128 No common boundaries are dissolved, all areas of the new map will be
129 assigned category number 1.
130
131 Extract vectors with SQL:
132 v.extract input=markveggy.shp output=markveggy.1 new=13 \
133 where="(VEGTYPE = ’Wi’) or (VEGTYPE = ’PS’) or (PRIME_TYPE=’Wi’)"
134
135 produces a new vector map with category number 13 if the SQL statement
136 is fulfilled.
137
138 Extract vector features which have the given field empty:
139 v.extract input=lakes output=lakes_gaps where="FTYPE is NULL"
140
141 Extract vector features which have the given field not empty:
142 v.extract input=lakes output=lakes_ftype where="FTYPE not NULL"
143
144 Reverse extracting (behaves like selective vector objects deleting):
145 Remove meteorological stations from map which are located above 1000m:
146 # check what to delete:
147 v.db.select precip_30ynormals where="elev > 1000"
148 # perform reverse selection
149 v.extract -r input=precip_30ynormals output=precip_30ynormals_lowland \
150 where="elev > 1000"
151 # verify
152 v.db.select precip_30ynormals_lowland
153
154 Dissolving based on column attributes:
155 # check column names:
156 v.info -c zipcodes_wake
157 # reclass based on desired column:
158 v.reclass input=zipcodes_wake output=zipcodes_wake_recl_nam column=ZIPNAME
159 # verify:
160 v.info -c zipcodes_wake_recl_nam
161 v.db.select zipcodes_wake_recl_nam
162 # dissolve:
163 v.extract -d input=zipcodes_wake_recl_nam output=zipcodes_wake_regions
164
165 This produces a new vector map with common boundaries dissolved where
166 the reclassed attributes of adjacent (left/right) areas are identical.
167
168 Extract 3 random areas from geology map
169 v.extract input=geology output=random_geology type=area random=3
170 This creates a new map with three random categories matching areas.
171 Note that there may be more than one feature with the same category.
172
174 v.category, v.dissolve, v.reclass, GRASS SQL interface
175
177 R.L. Glenn, USDA, SCS, NHQ-CGIS
178 GRASS 6 port by Radim Blazek
179
180 Last changed: $Date: 2016-03-16 21:17:59 +0100 (Wed, 16 Mar 2016) $
181
183 Available at: v.extract source code (history)
184
185 Main index | Vector index | Topics index | Keywords index | Graphical
186 index | Full index
187
188 © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
189
190
191
192GRASS 7.4.4 v.extract(1)