.TH v.vect.stats 1grass "" "GRASS 7.2.0" "Grass User's Manual" .SH NAME \fI\fBv.vect.stats\fR\fR \- Count points in areas, calculate statistics from point attributes. .SH KEYWORDS vector, attribute table, database, univariate statistics, zonal statistics .SH SYNOPSIS \fBv.vect.stats\fR .br \fBv.vect.stats \-\-help\fR .br \fBv.vect.stats\fR [\-\fBp\fR] \fBpoints\fR=\fIname\fR \fBareas\fR=\fIname\fR [\fBtype\fR=\fIstring\fR[,\fIstring\fR,...]] [\fBpoints_layer\fR=\fIstring\fR] [\fBareas_layer\fR=\fIstring\fR] [\fBmethod\fR=\fIstring\fR] [\fBpoints_column\fR=\fIname\fR] [\fBcount_column\fR=\fIstring\fR] [\fBstats_column\fR=\fIstring\fR] [\fBseparator\fR=\fIcharacter\fR] [\-\-\fBhelp\fR] [\-\-\fBverbose\fR] [\-\-\fBquiet\fR] [\-\-\fBui\fR] .SS Flags: .IP "\fB\-p\fR" 4m .br Print output to stdout, do not update attribute table .br First column is always area category .IP "\fB\-\-help\fR" 4m .br Print usage summary .IP "\fB\-\-verbose\fR" 4m .br Verbose module output .IP "\fB\-\-quiet\fR" 4m .br Quiet module output .IP "\fB\-\-ui\fR" 4m .br Force launching GUI dialog .SS Parameters: .IP "\fBpoints\fR=\fIname\fR \fB[required]\fR" 4m .br Name of input vector map .br Name of existing vector map with points .IP "\fBareas\fR=\fIname\fR \fB[required]\fR" 4m .br Name of input vector map .br Name of existing vector map with areas .IP "\fBtype\fR=\fIstring[,\fIstring\fR,...]\fR" 4m .br Feature type .br Input feature type .br Options: \fIpoint, centroid\fR .br Default: \fIpoint\fR .IP "\fBpoints_layer\fR=\fIstring\fR" 4m .br Layer number for points map .br Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. .br Default: \fI1\fR .IP "\fBareas_layer\fR=\fIstring\fR" 4m .br Layer number for area map .br Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name. .br Default: \fI1\fR .IP "\fBmethod\fR=\fIstring\fR" 4m .br Method for aggregate statistics .br Options: \fIsum, average, median, mode, minimum, min_cat, maximum, max_cat, range, stddev, variance, diversity\fR .IP "\fBpoints_column\fR=\fIname\fR" 4m .br Column name of points map to use for statistics .br Column of points map must be numeric .IP "\fBcount_column\fR=\fIstring\fR" 4m .br Column name to upload points count .br Column to hold points count, must be of type integer, will be created if not existing .IP "\fBstats_column\fR=\fIstring\fR" 4m .br Column name to upload statistics .br Column to hold statistics, must be of type double, will be created if not existing .IP "\fBseparator\fR=\fIcharacter\fR" 4m .br Field separator .br Special characters: pipe, comma, space, tab, newline .br Default: \fIpipe\fR .SH DESCRIPTION \fIv.vect.stats\fR counts the number of points in vector map \fIpoints\fR falling into each area in vector map \fIareas\fR. Optionally statistics on point attributes in \fIpoints\fR are calculated for each area. The results are either uploaded to the attribute table of the vector map \fIareas\fR or printed to stdout. .PP \fIStatistical Methods:\fR Using numeric attribute values of all points falling into a given area, a new value is detmined with the selected method. \fIv.vect.stats\fR can perform the following operations: .PP .IP "\fBsum\fR " 4m .br The sum of values. .IP "\fBaverage\fR " 4m .br The average value of all point attributes (sum / count). .IP "\fBmedian\fR " 4m .br The value found half\-way through a list of the attribute values, when these are ranged in numerical order. .IP "\fBmode\fR " 4m .br The most frequently occurring value. .IP "\fBminimum\fR " 4m .br The minimum observed value. .IP "\fBmin_cat\fR " 4m .br The point category corresponding to the minimum observed value. .IP "\fBmaximum\fR " 4m .br The maximum observed value. .IP "\fBmax_cat\fR " 4m .br The point category corresponding to the maximum observed value. .IP "\fBrange\fR " 4m .br The range of the observed values. .IP "\fBstddev\fR " 4m .br The statistical standard deviation of the attribute values. .IP "\fBvariance\fR " 4m .br The statistical variance of the attribute values. .IP "\fBdiversity\fR " 4m .br The number of different attribute values. .SH NOTES Points not falling into any area are ignored. Areas without category (no centroid attached or centroid without category) are ignored. If no points are falling into a given area, the point count is set to 0 (zero) and the statistics result to \(dqnull\(dq. .PP The columns \fIcount_column\fR and \fIstats_column\fR are created if not existing. If they do already exist, the \fIcount_column\fR must be of type integer and the \fIstats_column\fR of type double precision. .SH EXAMPLES .SS Preparation for examples The subsequent examples are based on randomly sampled elevation data (North Carolina sample database): .br .nf \fC # work on map copy for attribute editing g.copy vector=zipcodes_wake,myzipcodes_wake # set computational region: extent of ZIP code map, raster pixels # aligned to raster map g.region vector=myzipcodes_wake align=elev_state_500m \-p # generate random elevation points r.random elev_state_500m vector=rand5000 n=5000 v.colors rand5000 color=elevation # visualization d.mon wx0 d.vect myzipcodes_wake \-c d.vect rand5000 \fR .fi These vector maps are used for the examples below. .SS Count points per polygon with printed output \fISee above for the creation of the input maps.\fR .PP Counting points per polygon, print results to terminal: .br .nf \fC v.vect.stats points=rand5000 area=myzipcodes_wake \-p \fR .fi .SS Count points per polygon with column update \fISee above for the creation of the input maps.\fR .PP Counting of points per polygon, with update of \(dqnum_points\(dq column (will be automatically created): .br .nf \fC v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points # verify result v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,num_points \fR .fi .SS Average values of points in polygon with printed output \fISee above for the creation of the input maps.\fR .PP Calculation of average point elevation per ZIP code polygon, printed to terminal in comma separated style: .br .nf \fC # check name of point map column: v.info \-c rand5000 v.vect.stats points=rand5000 area=myzipcodes_wake \(rs method=average points_column=value separator=comma \-p \fR .fi .SS Average values of points in polygon with column update \fISee above for the creation of the input maps.\fR .PP Calculation of average point elevation per ZIP code polygon, with update of \(dqavg_elev\(dq column and counting of points per polygon, with update of \(dqnum_points\(dq column (new columns will be automatically created): .br .nf \fC # check name of point map column: v.info \-c rand5000 v.vect.stats points=rand5000 area=myzipcodes_wake count_column=num_points \(rs method=average points_column=value stats_column=avg_elev # verify result v.db.select myzipcodes_wake column=ZIPCODE_,ZIPNAME,avg_elev \fR .fi .SS Point statistics in a hexagonal grid The grid extent and size is influenced by the current computational region. The extent is based on the vector map \fIpoints_of_interest\fR from the basic North Carolina sample dataset. .br .nf \fC g.region vector=points_of_interest res=2000 \-pa \fR .fi The hexagonal grid is created using the \fIv.mkgrid\fR module as a vector map based on the previously selected extent and size of the grid. .br .nf \fC v.mkgrid map=hexagons \-h \fR .fi The \fIv.vect.stats\fR module counts the number of points and does one statistics on a selected column (here: \fIelev_m\fR). .br .nf \fC v.vect.stats points=points_of_interest areas=hexagons method=average \(rs points_column=elev_m count_column=count stats_column=average \fR .fi User should note that some of the points may be outside the grid since the hexagons cannot cover all the area around the edges (the computational region extent needs to be enlarged if all points should be considered). The last command sets the vector map color table to viridis based on the count column. .br .nf \fC v.colors map=hexagons use=attr column=average color=viridis \fR .fi .br Point statistics in a hexagonal grid (count of points, average of values associated with point, standard deviation) .SH SEE ALSO \fI v.distance, r.distance, v.rast.stats, v.what.vect, v.mkgrid \fR .SH AUTHOR Markus Metz .PP \fILast changed: $Date: 2016\-08\-23 04:07:22 +0200 (Tue, 23 Aug 2016) $\fR .SH SOURCE CODE .PP Available at: v.vect.stats source code (history) .PP Main index | Vector index | Topics index | Keywords index | Graphical index | Full index .PP © 2003\-2016 GRASS Development Team, GRASS GIS 7.2.0 Reference Manual