Zonal statistics: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
m (+screenshot)
(+example)
Line 18: Line 18:
* {{cmd|v.rast.stats}}: calculates univariate statistics from a raster map based on vector polygons and uploads statistics to new attribute columns
* {{cmd|v.rast.stats}}: calculates univariate statistics from a raster map based on vector polygons and uploads statistics to new attribute columns
* {{cmd|v.vect.stats|version=70}}: count points in areas, calculate statistics from point attributes (needs GRASS 7).
* {{cmd|v.vect.stats|version=70}}: count points in areas, calculate statistics from point attributes (needs GRASS 7).
=== Example ===
'''Task:''' calculate average temperature per country. Available maps: SHAPE file of countries, raster map of temperature.
'''Solution:''' First set the computational region to the vector map along with the desired raster resolution. Then convert the vector country map to raster using {{cmd|v.to.rast}}. Then run {{cmd|r.univar}} which offers zonal statistics using the country map on top of the temperature raster map. The command optionally outputs the result as table output format instead of standard output format.


[[Category: FAQ]]
[[Category: FAQ]]

Revision as of 19:36, 14 October 2012

GRASS GIS offers support for zonal statistics

Countries as zones for zonal statistics

Single maps

  • r.clump: finds all areas of contiguous raster cell category values in the input raster map and assigns a unique category value to each such area ("clump") in the resulting output raster map. This can be used to calculate statistics based on the clumps instead of individual raster cells.
  • r.report: report generator in various units
  • r.univar: univariate and zonal raster statistics
  • v.univar: univariate and zonal raster statistics
  • r.neighbors: makes each cell category value a function of the category values assigned to the cells around it, and stores new cell values in an output raster map layer.
  • v.neighbors: makes each cell value a function of the attribute values assigned to the vector points or centroids around it, and stores new cell values in an output raster map layer.

Multiple maps

  • r.univar: univariate and zonal raster statistics
  • v.rast.stats: calculates univariate statistics from a raster map based on vector polygons and uploads statistics to new attribute columns
  • v.vect.stats: count points in areas, calculate statistics from point attributes (needs GRASS 7).

Example

Task: calculate average temperature per country. Available maps: SHAPE file of countries, raster map of temperature.

Solution: First set the computational region to the vector map along with the desired raster resolution. Then convert the vector country map to raster using v.to.rast. Then run r.univar which offers zonal statistics using the country map on top of the temperature raster map. The command optionally outputs the result as table output format instead of standard output format.