1v.rast.stats(1)             GRASS GIS User's Manual            v.rast.stats(1)
2
3
4

NAME

6       v.rast.stats   -  Calculates  univariate  statistics  from a raster map
7       based on a vector map and uploads statistics to new attribute columns.
8

KEYWORDS

10       vector, statistics, raster, univariate  statistics,  zonal  statistics,
11       sampling, querying
12

SYNOPSIS

14       v.rast.stats
15       v.rast.stats --help
16       v.rast.stats           [-cd]          map=name           [layer=string]
17       [type=string[,string,...]]   [where=sql_query]   raster=name[,name,...]
18       column_prefix=string[,string,...]  [method=string[,string,...]]   [per‐
19       centile=integer]   [--help]  [--verbose]  [--quiet]  [--ui]
20
21   Flags:
22       -c
23           Continue if upload column(s) already exist
24
25       -d
26           Create densified lines (default: thin lines)
27           All cells touched by the line will be set, not only  those  on  the
28           render path
29
30       --help
31           Print usage summary
32
33       --verbose
34           Verbose module output
35
36       --quiet
37           Quiet module output
38
39       --ui
40           Force launching GUI dialog
41
42   Parameters:
43       map=name [required]
44           Name of vector map
45           Or data source for direct OGR access
46
47       layer=string
48           Layer number or name
49           Vector  features can have category values in different layers. This
50           number determines which layer to use. When used with direct OGR ac‐
51           cess this is the layer name.
52           Default: 1
53
54       type=string[,string,...]
55           Input feature type
56           Options: point, line, boundary, centroid, area
57           Default: point,line,boundary,centroid,area
58
59       where=sql_query
60           WHERE conditions of SQL statement without ’where’ keyword
61           Example: income < 1000 and population >= 10000
62
63       raster=name[,name,...] [required]
64           Name of input raster map to calculate statistics from
65
66       column_prefix=string[,string,...] [required]
67           Column prefix for new attribute columns
68
69       method=string[,string,...]
70           The methods to use
71           Options: number, null_cells, minimum, maximum, range, average, std‐
72           dev, variance, coeff_var, sum, first_quartile, median,  third_quar‐
73           tile, percentile
74           Default:       number,null_cells,minimum,maximum,range,average,std‐
75           dev,variance,coeff_var,sum,first_quartile,median,third_quar‐
76           tile,percentile
77
78       percentile=integer
79           Percentile to calculate
80           Options: 0-100
81           Default: 90
82

DESCRIPTION

84       v.rast.stats  calculates  basic univariate statistics from a raster map
85       only for the parts covered by the specified vector map.  The vector map
86       will  be  rasterized according to the raster map resolution.  Then uni‐
87       variate statistics are calculated per vector category  (cat)  from  the
88       raster  map and the results uploaded to the vector map attribute table.
89       A new column is generated in the attribute table for each statistic re‐
90       quested in method (if not already present).
91
92       The  univariate  statistics include the number of raster cells counted,
93       the number of raster NULL cells counted, minimum and maximum cell  val‐
94       ues, range, average, standard deviation, variance, coefficient of vari‐
95       ation, sum, first quartile, median, third quartile, and percentile.
96

NOTES

98       v.rast.stats is only meaningful for lines or polygons.
99
100       The module may take a long time to run if the raster region contains  a
101       large  number  of cells. In this case the --verbose flag may be used to
102       track progress.
103
104       The script stops if a (prefixed) upload column is  already  present  in
105       the vector map attribute table, unless otherwise instructed with the -c
106       continue flag. The column prefix will be separated from  the  statistic
107       name  with  an  underscore. For example with a prefix of "elev" the sum
108       column will be named elev_sum.
109
110       If a DBF database is being used, note that column names are  restricted
111       by  the  DBF specification to 10 characters. Therefore it is advised to
112       be economical in the use of the column prefix when using DBF as any ad‐
113       ditional characters will be chopped off.
114
115       If  a  MASK  is present, it will be restored after the script finished.
116       The script changes temporarily to the resolution of  the  given  raster
117       map.
118
119       If  an area has several categories in the selected layer (equivalent to
120       overlapping polygons in Simple Features), only  one  category  will  be
121       kept during the rasterization process. Statistics for the skipped cate‐
122       gories will thus be partial.
123
124       For example, if there are three areas: area 1 with cat 1, area  2  with
125       cat 2, area 3 with cats 1, 2. Only one category value of area 3 will be
126       used for rasterization, the other category value will be skipped.  Thus
127       statistics  for the used category value will be complete, while statis‐
128       tics for the skipped category value will be incomplete.
129
130       Large amounts of system memory can be  used  when  extended  statistics
131       (first_quartile,median,third_quartile,percentile  ) are being requested
132       with a very large region setting. If the region is too large the module
133       should display memory allocation errors. Basic statistics can be calcu‐
134       lated using any size input region.
135

EXAMPLES

137       Example to upload DEM statistics to ZIP codes vector  map  (North  Car‐
138       olina sample dataset):
139       g.copy vect=zipcodes_wake,myzipcodes_wake
140       # set computational region to DEM:
141       g.region raster=elevation -p
142       # calculate selected DEM statistics, upload to vector map table:
143       v.rast.stats myzipcodes_wake raster=elevation \
144         column_prefix=elev method=minimum,maximum,average,range,stddev,percentile \
145         percentile=95
146       # verify results:
147       v.info -c myzipcodes_wake
148       v.db.select myzipcodes_wake
149       v.univar myzipcodes_wake column=elev_range type=centroid
150

SEE ALSO

152          r.univar,   v.univar,   v.vect.stats,   v.what.rast,   v.what.rast3,
153       v.what.vect
154

AUTHOR

156       Markus Neteler, CEA (for the EDEN EU/FP6 Project)
157

SOURCE CODE

159       Available at: v.rast.stats source code (history)
160
161       Accessed: Mon Jun 20 16:47:46 2022
162
163       Main index | Vector index | Topics index | Keywords index  |  Graphical
164       index | Full index
165
166       © 2003-2022 GRASS Development Team, GRASS GIS 8.2.0 Reference Manual
167
168
169
170GRASS 8.2.0                                                    v.rast.stats(1)
Impressum