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 yet exist‐
166 ing. If they do already exist, the count_column must be of type integer
167 and the stats_column of type double precision.
168
169 In case that v.vect.stats complains about the points_column of the
170 input points vector map not being numeric, the module v.db.update can
171 be used to perform type casting, i.e. adding and populating an addi‐
172 tional numeric column with the values type converted from string
173 attributes to floating point numbers.
174
176 Preparation for examples
177 The subsequent examples are based on randomly sampled elevation data
178 (North Carolina sample database):
179 # work on map copy for attribute editing
180 g.copy vector=zipcodes_wake,myzipcodes_wake
181 # set computational region: extent of ZIP code map, raster pixels
182 # aligned to raster map
183 g.region vector=myzipcodes_wake align=elev_state_500m -p
184 # generate random elevation points
185 r.random elev_state_500m vector=rand5000 n=5000
186 v.colors rand5000 color=elevation
187 # visualization
188 d.mon wx0
189 d.vect myzipcodes_wake -c
190 d.vect rand5000
191 These vector maps are used for the examples below.
192
193 Count points per polygon with printed output
194 See above for the creation of the input maps.
195
196 Counting points per polygon, print results to terminal:
197 v.vect.stats points=rand5000 area=myzipcodes_wake -p
198
199 Count points per polygon with column update
200 See above for the creation of the input maps.
201
202 Counting of points per polygon, with update of "num_points" column
203 (will be automatically created):
204 v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points
205 # verify result
206 v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,num_points
207
208 Average values of points in polygon with printed output
209 See above for the creation of the input maps.
210
211 Calculation of average point elevation per ZIP code polygon, printed to
212 terminal in comma separated style:
213 # check name of point map column:
214 v.info -c rand5000
215 v.vect.stats points=rand5000 area=myzipcodes_wake \
216 method=average points_column=value separator=comma -p
217
218 Average values of points in polygon with column update
219 See above for the creation of the input maps.
220
221 Calculation of average point elevation per ZIP code polygon, with
222 update of "avg_elev" column and counting of points per polygon, with
223 update of "num_points" column (new columns will be automatically cre‐
224 ated):
225 # check name of point map column:
226 v.info -c rand5000
227 v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points \
228 method=average points_column=value stats_column=avg_elev
229 # verify result
230 v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,avg_elev
231
232 Point statistics in a hexagonal grid
233 The grid extent and size is influenced by the current computational
234 region. The extent is based on the vector map points_of_interest from
235 the basic North Carolina sample dataset.
236 g.region vector=points_of_interest res=2000 -pa
237 The hexagonal grid is created using the v.mkgrid module as a vector map
238 based on the previously selected extent and size of the grid.
239 v.mkgrid map=hexagons -h
240 The v.vect.stats module counts the number of points and does one sta‐
241 tistics on a selected column (here: elev_m).
242 v.vect.stats points=points_of_interest areas=hexagons method=average \
243 points_column=elev_m count_column=count stats_column=average
244 User should note that some of the points may be outside the grid since
245 the hexagons cannot cover all the area around the edges (the computa‐
246 tional region extent needs to be enlarged if all points should be con‐
247 sidered). The last command sets the vector map color table to viridis
248 based on the count column.
249 v.colors map=hexagons use=attr column=average color=viridis
250 Point statistics in a hexagonal grid (count of points, average of val‐
251 ues associated with point, standard deviation)
252
254 v.distance, r.distance, v.rast.stats, v.what.vect, v.mkgrid
255
257 Markus Metz
258
260 Available at: v.vect.stats source code (history)
261
262 Main index | Vector index | Topics index | Keywords index | Graphical
263 index | Full index
264
265 © 2003-2019 GRASS Development Team, GRASS GIS 7.8.2 Reference Manual
266
267
268
269GRASS 7.8.2 v.vect.stats(1)