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

NAME

6       r.stats  - Generates area statistics for raster map.
7

KEYWORDS

9       raster, statistics
10

SYNOPSIS

12       r.stats
13       r.stats --help
14       r.stats  [-acpl1gxArnNCi] input=name[,name,...]  [output=name]   [sepa‐
15       rator=character]          [null_value=string]          [nsteps=integer]
16       [sort=string]   [--overwrite]  [--help]  [--verbose]  [--quiet]  [--ui]
17
18   Flags:
19       -a
20           Print area totals in square meters
21
22       -c
23           Print cell counts (sortable)
24
25       -p
26           Print approximate (total percent may not be 100%) percents
27
28       -l
29           Print category labels
30
31       -1
32           One cell (range) per line
33
34       -g
35           Print grid coordinates (east and north)
36
37       -x
38           Print x and y (column and row)
39           Indexing starts with 1: first column and row are 1
40
41       -A
42           Print  averaged  values  instead  of intervals (floating-point maps
43           only)
44
45       -r
46           Print raw indexes of  floating-point  ranges  (floating-point  maps
47           only)
48
49       -n
50           Do not report no data value
51
52       -N
53           Do not report cells where all maps have no data
54
55       -C
56           Report for cats floating-point ranges (floating-point maps only)
57
58       -i
59           Read floating-point map as integer (use map’s quant rules)
60
61       --overwrite
62           Allow output files to overwrite existing files
63
64       --help
65           Print usage summary
66
67       --verbose
68           Verbose module output
69
70       --quiet
71           Quiet module output
72
73       --ui
74           Force launching GUI dialog
75
76   Parameters:
77       input=name[,name,...] [required]
78           Name of raster map(s) to report on
79
80       output=name
81           Name for output file (if omitted or "-" output to stdout)
82
83       separator=character
84           Field separator
85           Special characters: pipe, comma, space, tab, newline
86           Default: space
87
88       null_value=string
89           String representing NULL value
90           Default: *
91
92       nsteps=integer
93           Number of floating-point subranges to collect stats from
94           Default: 255
95
96       sort=string
97           Sort output statistics by cell counts
98           Default: sorted by categories or intervals
99           Options: asc, desc
100           asc: Sort by cell counts in ascending order
101           desc: Sort by cell counts in descending order
102

DESCRIPTION

104       r.stats calculates the area present in each of the categories or float‐
105       ing-point intervals of user-selected input raster map. Area  statistics
106       are  given  in units of square meters and/or cell counts. This analysis
107       uses  the  current  geographic  region  (g.region)  and  mask  settings
108       (r.mask). The output statistics can be saved to a output file.
109
110       Area  statistics  is printed in square meters for each category when -a
111       is given. Similarly if -c flag is chosen, areas will be stated also  in
112       number of cells.
113

NOTES

115       If  a  single  raster  map  is  specified, a list of categories will be
116       printed.  The -x flag will print x and y (column and row) starting with
117       1  (both  first  row  and first column are indexed with 1). If multiple
118       raster maps are specified, a cross-tabulation table for  each  combina‐
119       tion of categories in the raster maps will be printed.
120
121       For  example,  if  one  raster map was specified, the output would look
122       like:
123       1 1350000.00
124       2 4940000.00
125       3 8870000.00
126       If three raster maps were specified, the output would look like:
127       0 0 0 8027500.00
128       0 1 0 1152500.00
129       1 0 0 164227500.00
130       1 0 1 2177500.00
131       1 1 0 140092500.00
132       1 1 1 3355000.00
133       2 0 0 31277500.00
134       2 0 1 2490000.00
135       2 1 0 24207500.00
136       2 1 1 1752500.00
137       3 0 0 17140000.00
138       3 1 0 11270000.00
139       3 1 1 2500.00
140       Within each grouping, the first field represents the category value  of
141       first  raster map, the second represents the category values associated
142       with second raster map, the third represents category values for  third
143       raster  map, and the last field gives the area in square meters for the
144       particular combination of these three raster maps’ categories. For  ex‐
145       ample,  above, combination 3,1,1 covered 2500 square meters. Fields are
146       separated by the separator option.  The output from r.stats  is  sorted
147       by category or category intervals (for floating-point raster maps).
148
149       Note  that the user has only the option of printing out cell statistics
150       in terms of cell counts and/or area totals. Users wishing to  use  dif‐
151       ferent units than are available here should use r.report.
152

EXAMPLES

154   Report area for each category
155       Report area for each category in the single raster map:
156       g.region raster=geology_30m
157       r.stats -a in=geology_30m nv=no-data sep=tab
158       217     71960000.000000
159       262     19760000.000000
160       270     67760000.000000
161       405     25120000.000000
162       583     2520000.000000
163       720     480000.000000
164       766     840000.000000
165       862     6560000.000000
166       910     4360000.000000
167       921     1200000.000000
168       946     360000.000000
169       948     80000.000000
170       no-data 33375200000.000004
171
172   Report sorted number of cells for each category
173       Report  sorted  number  of cells for each category in the single raster
174       map (suppress NULL data):
175       g.region raster=geology_30m
176       r.stats -cn input=geology_30m sort=desc
177       217 1799
178       270 1694
179       405 628
180       262 494
181       862 164
182       910 109
183       583 63
184       921 30
185       766 21
186       720 12
187       946 9
188       948 2
189
190   Report area, number of cells, and percents in multiple raster maps
191       Report area, number of cells, and percents (separated by tabs) for each
192       category in multiple raster maps (suppress NULL data):
193       g.region raster=towns
194       r.stats -nacp input=towns,urban separator=tab
195       1       55      23840000.000000 596     11.89%
196       2       55      13680000.000000 342     6.82%
197       3       55      1360000.000000  34      0.68%
198       4       55      16040000.000000 401     8.00%
199       5       55      98240000.000000 2456    48.98%
200       6       55      19760000.000000 494     9.85%
201
202   Report sorted area intervals of floating-point raster map
203       Report  sorted  area  for  each interval of floating-point input raster
204       map. Number of intervals are given by nsteps option.
205       g.region raster=elevation
206       r.stats -an input=elevation nsteps=10 sort=desc separator=tab
207       95.879221-105.954329    36440000.000000
208       85.804114-95.879221     30800000.000000
209       105.954329-116.029436   30080000.000000
210       116.029436-126.104543   27960000.000000
211       126.104543-136.17965    26440000.000000
212       136.17965-146.254757    20880000.000000
213       75.729007-85.804114     15880000.000000
214       65.6539-75.729007       6040000.000000
215       146.254757-156.329865   5720000.000000
216       55.578793-65.6539       760000.000000
217
218   Report raster cell counts in multiple raster maps
219       Report raster cell counts of landuse and geological  categories  within
220       zipcode areas:
221       g.region raster=zipcodes
222       # landuse/landcover and zipcodes
223       r.stats -c input=landclass96,zipcodes separator=comma
224       # landuse/landcover, geology and zipcodes with category labels
225       r.stats -c input=landclass96,zipcodes,geology_30m separator=comma -l
226

SEE ALSO

228           g.region,    r.report,    r.coin,   r.describe,   r.stats.quantile,
229       r.stats.zonal, r.statistics, r.univar
230

AUTHORS

232       Michael Shapiro, U.S. Army Construction Engineering Research Laboratory
233       Sort option by Martin Landa, Czech Technical University in Prague, 2013
234

SOURCE CODE

236       Available at: r.stats source code (history)
237
238       Accessed: Saturday Jan 21 21:15:13 2023
239
240       Main index | Raster index | Topics index | Keywords index  |  Graphical
241       index | Full index
242
243       © 2003-2023 GRASS Development Team, GRASS GIS 8.2.1 Reference Manual
244
245
246
247GRASS 8.2.1                                                         r.stats(1)
Impressum