[GRASS-user] raster area calculations in lat/long

Hamish hamish_b at yahoo.com
Sun Jun 15 04:03:35 EDT 2008


Hi Jerry,

> I'm a new grass user and have been learning on the command line.
> I have a raster file of the world in which the cells are floating
> point values of the percentage of a crop type within that cell (ex.,
> 0.01, 0.29, 0.45).  It's in Lat/Long.  I want to calculate the
> total area of crop in specific regions that are defined in a separate
> raster file.  I want to multiply the value of the cell by the cell
> area and then sum the cell values in each region to get total acreage.
> My questions are: 1) Can I do this in r.stats, r.report or r.coin, or
> do I need to use r.mapcalc?,

see also r.statistics, r.sum, r.univar, r.reclass(.area), ....
I'm not enough of an expert with using the cover map functions to answer this well. Regardless r.mapcalc should be flexible enough to do what you like as a worst case scenario.
sounds like a fairly standard & straight forward task though.


> and 2) Because my files are in lat/long, the area covered by each
> cell changes based on its latitude.  Can this be accounted for
> in trying to come with total area?

AFAICT from a quick look at the code, r.report and r.coin are just
friendly front-ends to r.stats. So the question reduces to: does
r.stats account for changing cell area with latitude?  -- It does.

specifically r.stats calls these libgis functions:
 G_begin_cell_area_calculations()
 G_area_of_cell_at_row()

so it recalculates the cell area for each cell row for lat/lon.
for more detail read the code comments for those functions in:
 http://trac.osgeo.org/grass/browser/grass/trunk/lib/gis/area.c
(or the GRASS programmer's manual)


If you like, reproject the maps to an equal-area map projection and double check that the results are similar.

if you were really keen you could try to write your own module in C or with the swig/python interface for the calc. But the existing modules should give you all the tools you need from the command line.


Hamish



      



More information about the grass-user mailing list