[GRASS-user] Area statistics for categorical maps

Nikos Alexandris nik at nikosalexandris.net
Sun Jul 29 05:10:39 PDT 2018


Recently, I "discovered" that `r.stats` and `r.report` accept multiple
raster input maps. Which is fantastic!

I am yet to find my "ideal" reporting method
for when involving 3 (or more) raster maps.

- `r.stats` reports _approximate_ percentages that
    refer to the complete extent of the computational region and
    has a CSV frinedly output than `r.report`.

- `r.report`, however, derives percentages that
    refer to the extent of the (preceding input raster map's)
    "super-category", which is useful.

Maybe "fix" `r.stats` to (also) provide
an option to get percentages relative to a "super-category"?

An example:

| 501|                                                |  3.405000| 1362|  4.50|
|    |------------------------------------------------|----------|-----|------|
|    |1|Urban. . . . . . . . . . . . . . . . . . . . .|  0.820000|  328| 24.08|
|    |2|Cropland . . . . . . . . . . . . . . . . . . .|  1.260000|  504| 37.00|
|    |3|Woodland and forest. . . . . . . . . . . . . .|  1.325000|  530| 38.91|

and (r.stats' output piped through `column -t`)

501   1  820000.000000    328   1.08%
501   2  1260000.000000   504   1.67%
501   3  1325000.000000   530   1.75%

where:

- 501 is some map's category/pixel value, a map without labeled categories
- the second map's categories 1, 2 and 3 are labeled

- the first fragment comes from an `r.report` output
- the second fragment comes from an `r.stats` output

- km (above) and meters (below) agree
- pixel counts agree
- percentages don't agree, of course

`r.stats` will report these relative percentages by using the
"super-category" as a MASK. Using the first map and the value '501' as a
MASK, the results are:

|501|                                                 |  3.520000| 1408|100.00|
|   |-------------------------------------------------|----------|-----|------|
|   |1|Urban. . . . . . . . . . . . . . . . . . . . . |  0.935000|  374| 26.56|
|   |2|Cropland . . . . . . . . . . . . . . . . . . . |  1.260000|  504| 35.80|
|   |3|Woodland and forest. . . . . . . . . . . . . . |  1.325000|  530| 37.64|

and

501  1  935000.000000   374  26.64%
501  2  1260000.000000  504  35.90%
501  3  1325000.000000  530  37.75%

The obvious problem is: `r.stats` if CSV friendly but gives
approximations, `r.report` is not CSV friendly but the sum of relative
percentages sum up to 100%.

How do you report areal statistics?

See also: https://trac.osgeo.org/grass/ticket/507

Nikos
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 228 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20180729/b76bcf52/attachment.sig>


More information about the grass-user mailing list