1r.univar(1)                   Grass User's Manual                  r.univar(1)
2
3
4

NAME

6       r.univar  - Calculates univariate statistics from the non-null cells of
7       a raster map.
8       Statistics include number of cells counted, minimum  and  maximum  cell
9       values,  range,  arithmetic  mean, population variance, standard devia‐
10       tion, coefficient of variation, and sum.
11

KEYWORDS

13       raster, statistics, univariate statistics, zonal statistics
14

SYNOPSIS

16       r.univar
17       r.univar --help
18       r.univar  [-getr]  map=name[,name,...]   [zones=name]     [output=name]
19       [percentile=float[,float,...]]    [separator=character]   [--overwrite]
20       [--help]  [--verbose]  [--quiet]  [--ui]
21
22   Flags:
23       -g
24           Print the stats in shell script style
25
26       -e
27           Calculate extended statistics
28
29       -t
30           Table output format instead of standard output format
31
32       -r
33           Use the native resolution and extent of the raster map, instead  of
34           the current region
35
36       --overwrite
37           Allow output files to overwrite existing files
38
39       --help
40           Print usage summary
41
42       --verbose
43           Verbose module output
44
45       --quiet
46           Quiet module output
47
48       --ui
49           Force launching GUI dialog
50
51   Parameters:
52       map=name[,name,...] [required]
53           Name of raster map(s)
54
55       zones=name
56           Raster map used for zoning, must be of type CELL
57
58       output=name
59           Name for output file (if omitted or "-" output to stdout)
60
61       percentile=float[,float,...]
62           Percentile to calculate (requires extended statistics flag)
63           Options: 0-100
64           Default: 90
65
66       separator=character
67           Field separator
68           Special characters: pipe, comma, space, tab, newline
69           Default: pipe
70

DESCRIPTION

72       r.univar  calculates the univariate statistics of one or several raster
73       map(s). This includes the number of cells counted, minimum and  maximum
74       cell  values,  range,  arithmetic  mean,  population variance, standard
75       deviation, coefficient of variation, and sum. Statistics are calculated
76       separately  for  every  category/zone  found  in the zones input map if
77       given.  If the -e extended statistics flag is given the  1st  quartile,
78       median,  3rd  quartile, and given percentile are calculated.  If the -g
79       flag is given the results are presented in a format suitable for use in
80       a  shell  script.  If the -t flag is given the results are presented in
81       tabular format with the given field separator. The  table  can  immedi‐
82       ately be converted to a vector attribute table which can then be linked
83       to a vector, e.g. the vector that was rasterized to  create  the  zones
84       input raster.
85
86       When  multiple input maps are given to r.univar, the overall statistics
87       are calculated. This is useful for a time series of the same  variable,
88       as well as for the case of a segmented/tiled dataset. Allowing multiple
89       raster maps to be specified saves  the  user  from  using  a  temporary
90       raster map for the result of r.series or r.patch.
91

NOTES

93       As  with  most  GRASS  raster  modules, r.univar operates on the raster
94       array defined by the current region settings, not the  original  extent
95       and  resolution  of the input map. See g.region, but also the wiki page
96       on the computational region to understand the impact of the region set‐
97       tings on the calculations.
98
99       This module can use large amounts of system memory when the -e extended
100       statistics flag is used with a very large region setting. If the region
101       is too large the module should exit gracefully with a memory allocation
102       error. Basic statistics can be calculated using any size input  region.
103       Extended statistics can be calculated using r.stats.quantile.
104
105       Without  a  zones  input raster, the r.quantile module will be signifi‐
106       cantly more efficient for calculating percentiles with large maps.
107
108       For calculating univariate statistics from a raster map based on vector
109       polygon  map  and  uploads  statistics  to  new  attribute columns, see
110       v.rast.stats.
111

EXAMPLES

113   Univariate statistics
114       In this example, the raster map elevation in the North Carolina  sample
115       dataset is used to calculate univariate statistics:
116       g.region raster=elevation -p
117       # standard output, along with extended statistics
118       r.univar -e elevation percentile=98
119       total null and non-null cells: 2025000
120       total null cells: 0
121       Of the non-null cells:
122       ----------------------
123       n: 2025000
124       minimum: 55.5788
125       maximum: 156.33
126       range: 100.751
127       mean: 110.375
128       mean of absolute values: 110.375
129       standard deviation: 20.3153
130       variance: 412.712
131       variation coefficient: 18.4057 %
132       sum: 223510266.558102
133       1st quartile: 94.79
134       median (even number of cells): 108.88
135       3rd quartile: 126.792
136       98th percentile: 147.727
137       # script style output, along with extended statistics
138       r.univar -ge elevation percentile=98
139       n=2025000
140       null_cells=0
141       cells=2025000
142       min=55.5787925720215
143       max=156.329864501953
144       range=100.751071929932
145       mean=110.375440275606
146       mean_of_abs=110.375440275606
147       stddev=20.3153233205981
148       variance=412.712361620436
149       coeff_var=18.4056555243368
150       sum=223510266.558102
151       first_quartile=94.79
152       median=108.88
153       third_quartile=126.792
154       percentile_98=147.727
155
156   Zonal statistics
157       In  this  example,  the raster polygon map basins in the North Carolina
158       sample dataset is used to calculate raster  statistics  for  zones  for
159       elevation raster map:
160       g.region raster=basins -p
161       This will set and print computational region in the format:
162       projection: 99 (Lambert Conformal Conic)
163       zone:       0
164       datum:      nad83
165       ellipsoid:  a=6378137 es=0.006694380022900787
166       north:      228500
167       south:      215000
168       west:       630000
169       east:       645000
170       nsres:      10
171       ewres:      10
172       rows:       1350
173       cols:       1500
174       cells:      2025000
175       Check basin’s IDs using:
176       r.category basins
177       This will print them in the format:
178       2
179       4
180       6
181       8
182       10
183       12
184       14
185       16
186       18
187       20
188       22
189       24
190       26
191       28
192       30
193       Visualization of them underlying elevation map can be created as:
194       d.mon wx0
195       d.rast map=elevation
196       r.colors map=elevation color=grey
197       d.rast map=basins
198       r.colors map=basins color=bgyr
199       d.legend raster=basins use=2,4,6,8,10,12,14,16,18,20,22,24,26,28,30
200       d.barscale
201       Figure:  Zones (basins, opacity: 60%) with underlying elevation map for
202       North Carolina sample dataset.
203
204       Then statistics for elevation can be calculated  separately  for  every
205       zone, i.e. basin found in the zones parameter:
206       r.univar -t map=elevation zones=basins separator=comma \
207                output=basin_elev_zonal.csv
208       This will print information in the format:
209       zone,label,non_null_cells,null_cells,min,max,range,mean,mean_of_abs,
210       stddev,variance,coeff_var,sum,sum_abs2,,116975,0,55.5787925720215,
211       133.147018432617,77.5682258605957,92.1196971445722,92.1196971445722,
212       15.1475301152556,229.447668592576,16.4433129773355,10775701.5734863,
213       10775701.57348634,,75480,0,61.7890930175781,110.348838806152,
214       48.5597457885742,83.7808205765268,83.7808205765268,11.6451777476995,
215       135.610164775515,13.8995747088232,6323776.33711624,6323776.33711624
216       6,,1137,0,66.9641571044922,83.2070922851562,16.2429351806641,
217       73.1900814395257,73.1900814395257,4.15733292896409,17.2834170822492,
218       5.68018623179036,83217.1225967407,83217.12259674078,,80506,
219       0,67.4670791625977,147.161514282227, ...
220       Comma  Separated Values (CSV) file is best viewed through a spreadsheet
221       program such as Microsoft Excel, Libre/Open Office Calc or Google Docs:
222       Figure: Raster statistics for  zones  (basins,  North  Carolina  sample
223       dataset) viewed through Libre/Open Office Calc.
224

TODO

226       To be implemented mode, skewness, kurtosis.
227

SEE ALSO

229          g.region,   r3.univar,   r.mode,   r.quantile,   r.series,  r.stats,
230       r.stats.quantile, r.stats.zonal, r.statistics, v.rast.stats, v.univar
231

AUTHORS

233       Hamish Bowman, Otago University, New Zealand
234       Extended statistics by Martin Landa
235       Multiple input map support by Ivan Shmakov
236       Zonal loop by Markus Metz
237

SOURCE CODE

239       Available at: r.univar source code (history)
240
241       Main index | Raster index | Topics index | Keywords index  |  Graphical
242       index | Full index
243
244       © 2003-2019 GRASS Development Team, GRASS GIS 7.8.2 Reference Manual
245
246
247
248GRASS 7.8.2                                                        r.univar(1)
Impressum