1v.vect.stats(1) Grass User's Manual v.vect.stats(1)
2
3
4
6 v.vect.stats - Count points in areas, calculate statistics from point
7 attributes.
8
10 vector, attribute table, database, univariate statistics, zonal statis‐
11 tics
12
14 v.vect.stats
15 v.vect.stats --help
16 v.vect.stats [-p] points=name areas=name [type=string[,string,...]]
17 [points_layer=string] [points_cats=range] [points_where=sql_query]
18 [areas_layer=string] [areas_cats=range] [areas_where=sql_query]
19 [method=string] [points_column=name] [count_column=name]
20 [stats_column=name] [separator=character] [--help] [--verbose]
21 [--quiet] [--ui]
22
23 Flags:
24 -p
25 Print output to stdout, do not update attribute table
26 First column is always area category
27
28 --help
29 Print usage summary
30
31 --verbose
32 Verbose module output
33
34 --quiet
35 Quiet module output
36
37 --ui
38 Force launching GUI dialog
39
40 Parameters:
41 points=name [required]
42 Name of existing vector map with points
43 Or data source for direct OGR access
44
45 areas=name [required]
46 Name of existing vector map with areas
47 Or data source for direct OGR access
48
49 type=string[,string,...]
50 Feature type
51 Input feature type
52 Options: point, centroid
53 Default: point
54
55 points_layer=string
56 Layer number for points map
57 Vector features can have category values in different layers. This
58 number determines which layer to use. When used with direct OGR
59 access this is the layer name.
60 Default: 1
61
62 points_cats=range
63 Category values for points map
64 Example: 1,3,7-9,13
65
66 points_where=sql_query
67 WHERE conditions of SQL statement without ’where’ keyword for
68 points map
69 Example: income < 1000 and population >= 10000
70
71 areas_layer=string
72 Layer number for area map
73 Vector features can have category values in different layers. This
74 number determines which layer to use. When used with direct OGR
75 access this is the layer name.
76 Default: 1
77
78 areas_cats=range
79 Category values for area map
80 Example: 1,3,7-9,13
81
82 areas_where=sql_query
83 WHERE conditions of SQL statement without ’where’ keyword for area
84 map
85 Example: income < 1000 and population >= 10000
86
87 method=string
88 Method for aggregate statistics
89 Options: sum, average, median, mode, minimum, min_cat, maximum,
90 max_cat, range, stddev, variance, diversity
91
92 points_column=name
93 Column name of points map to use for statistics
94 Column of points map must be numeric
95
96 count_column=name
97 Column name to upload points count
98 Column to hold points count, must be of type integer, will be cre‐
99 ated if not existing
100
101 stats_column=name
102 Column name to upload statistics
103 Column to hold statistics, must be of type double, will be created
104 if not existing
105
106 separator=character
107 Field separator
108 Special characters: pipe, comma, space, tab, newline
109 Default: pipe
110
112 v.vect.stats counts the number of points in vector map points falling
113 into each area in vector map areas. Optionally statistics on point
114 attributes in points are calculated for each area. The results are
115 either uploaded to the attribute table of the vector map areas or
116 printed to stdout.
117
118 Statistical Methods: Using numeric attribute values of all points fall‐
119 ing into a given area, a new value is detmined with the selected
120 method. v.vect.stats can perform the following operations:
121
122 sum
123 The sum of values.
124
125 average
126 The average value of all point attributes (sum / count).
127
128 median
129 The value found half-way through a list of the attribute values,
130 when these are ranged in numerical order.
131
132 mode
133 The most frequently occurring value.
134
135 minimum
136 The minimum observed value.
137
138 min_cat
139 The point category corresponding to the minimum observed value.
140
141 maximum
142 The maximum observed value.
143
144 max_cat
145 The point category corresponding to the maximum observed value.
146
147 range
148 The range of the observed values.
149
150 stddev
151 The statistical standard deviation of the attribute values.
152
153 variance
154 The statistical variance of the attribute values.
155
156 diversity
157 The number of different attribute values.
158
160 Points not falling into any area are ignored. Areas without category
161 (no centroid attached or centroid without category) are ignored. If no
162 points are falling into a given area, the point count is set to 0
163 (zero) and the statistics result to "null".
164
165 The columns count_column and stats_column are created if not existing.
166 If they do already exist, the count_column must be of type integer and
167 the stats_column of type double precision.
168
170 Preparation for examples
171 The subsequent examples are based on randomly sampled elevation data
172 (North Carolina sample database):
173 # work on map copy for attribute editing
174 g.copy vector=zipcodes_wake,myzipcodes_wake
175 # set computational region: extent of ZIP code map, raster pixels
176 # aligned to raster map
177 g.region vector=myzipcodes_wake align=elev_state_500m -p
178 # generate random elevation points
179 r.random elev_state_500m vector=rand5000 n=5000
180 v.colors rand5000 color=elevation
181 # visualization
182 d.mon wx0
183 d.vect myzipcodes_wake -c
184 d.vect rand5000
185 These vector maps are used for the examples below.
186
187 Count points per polygon with printed output
188 See above for the creation of the input maps.
189
190 Counting points per polygon, print results to terminal:
191 v.vect.stats points=rand5000 area=myzipcodes_wake -p
192
193 Count points per polygon with column update
194 See above for the creation of the input maps.
195
196 Counting of points per polygon, with update of "num_points" column
197 (will be automatically created):
198 v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points
199 # verify result
200 v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,num_points
201
202 Average values of points in polygon with printed output
203 See above for the creation of the input maps.
204
205 Calculation of average point elevation per ZIP code polygon, printed to
206 terminal in comma separated style:
207 # check name of point map column:
208 v.info -c rand5000
209 v.vect.stats points=rand5000 area=myzipcodes_wake \
210 method=average points_column=value separator=comma -p
211
212 Average values of points in polygon with column update
213 See above for the creation of the input maps.
214
215 Calculation of average point elevation per ZIP code polygon, with
216 update of "avg_elev" column and counting of points per polygon, with
217 update of "num_points" column (new columns will be automatically cre‐
218 ated):
219 # check name of point map column:
220 v.info -c rand5000
221 v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points \
222 method=average points_column=value stats_column=avg_elev
223 # verify result
224 v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,avg_elev
225
226 Point statistics in a hexagonal grid
227 The grid extent and size is influenced by the current computational
228 region. The extent is based on the vector map points_of_interest from
229 the basic North Carolina sample dataset.
230 g.region vector=points_of_interest res=2000 -pa
231 The hexagonal grid is created using the v.mkgrid module as a vector map
232 based on the previously selected extent and size of the grid.
233 v.mkgrid map=hexagons -h
234 The v.vect.stats module counts the number of points and does one sta‐
235 tistics on a selected column (here: elev_m).
236 v.vect.stats points=points_of_interest areas=hexagons method=average \
237 points_column=elev_m count_column=count stats_column=average
238 User should note that some of the points may be outside the grid since
239 the hexagons cannot cover all the area around the edges (the computa‐
240 tional region extent needs to be enlarged if all points should be con‐
241 sidered). The last command sets the vector map color table to viridis
242 based on the count column.
243 v.colors map=hexagons use=attr column=average color=viridis
244 Point statistics in a hexagonal grid (count of points, average of val‐
245 ues associated with point, standard deviation)
246
248 v.distance, r.distance, v.rast.stats, v.what.vect, v.mkgrid
249
251 Markus Metz
252
253 Last changed: $Date: 2016-08-23 04:00:20 +0200 (Tue, 23 Aug 2016) $
254
256 Available at: v.vect.stats source code (history)
257
258 Main index | Vector index | Topics index | Keywords index | Graphical
259 index | Full index
260
261 © 2003-2019 GRASS Development Team, GRASS GIS 7.4.4 Reference Manual
262
263
264
265GRASS 7.4.4 v.vect.stats(1)