Raster aggregate values: Difference between revisions

From GRASS-Wiki
Jump to navigation Jump to search
(new, based on Hamish's notes)
 
m (added some details regarding r.resamp.stats)
 
(One intermediate revision by one other user not shown)
Line 7: Line 7:
* Draw a 1 km x 1 km grid ({{cmd|d.grid}}), and overlay the {{cmd|v.mkgrid}} vector map (area fill = none, or only display boundary features, colored red or so) just to verify where it will be and what it will look like.
* Draw a 1 km x 1 km grid ({{cmd|d.grid}}), and overlay the {{cmd|v.mkgrid}} vector map (area fill = none, or only display boundary features, colored red or so) just to verify where it will be and what it will look like.
* Run {{cmd|v.rast.stats}} to calculate stats for each grid box, and upload to that area's attribute table.
* Run {{cmd|v.rast.stats}} to calculate stats for each grid box, and upload to that area's attribute table.
'''A:''' Another approach using {{cmd|r.resamp.stats}}:
* Generate a region that defines the required grid topology: extent, cell size, origin
* Zoom to that region, and set the resolution accordingly
* Aggregate slope values within each of the cells defined by this new region using {{cmd|r.resamp.stats}}
* The resulting raster will contain aggregate values of the input raster, using the new grid topology
* Optionally vectorize with {{cmd|r.to.vect}}


[[category: FAQ]]
[[category: FAQ]]

Latest revision as of 15:49, 26 August 2010

Q: How can I calculate the average map values by spatial unit (grid)? For example, I would like to calculate the average slope by square kilometer for a given area.

A: Procedure outline:

  • Make a slope map from the DEM with r.slope.aspect at the same resolution and bounds as the DEM. (run 'g.region rast=dem' first)
  • Make the grid with v.mkgrid, with box=1000,1000 (assuming the location is meters-based)
  • Draw a 1 km x 1 km grid (d.grid), and overlay the v.mkgrid vector map (area fill = none, or only display boundary features, colored red or so) just to verify where it will be and what it will look like.
  • Run v.rast.stats to calculate stats for each grid box, and upload to that area's attribute table.

A: Another approach using r.resamp.stats:

  • Generate a region that defines the required grid topology: extent, cell size, origin
  • Zoom to that region, and set the resolution accordingly
  • Aggregate slope values within each of the cells defined by this new region using r.resamp.stats
  • The resulting raster will contain aggregate values of the input raster, using the new grid topology
  • Optionally vectorize with r.to.vect