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

Jerry Griffith j7g at geobabble.org
Mon Jun 30 10:29:57 EDT 2008


Ok, since GRASS does account for differing cell size in lat/long raster 
files, what I am after is mapcalc is to do something like:

croparea = [cellsize] * corn_map (my corn_map has a floating point 
value, ex. 0.29 that gives the fraction of the cell that is in corn 

I have tried simply typing in for [cellsize] the functions listed below, 
but that doesn't work or my syntax is wrong.


and I haven't found in r.stats or related commands that allows an 
intermediate multiplication step. I have tried using r.proj (and with 
-n) to reproject to an equal area projection, but my crop maps are 
global coverages and the other Locations in lambert equal area are for 
the US, so the result is my global crop maps get clipped to the US.

Thanks very much,


Hamish wrote:
> 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)
> Hamish

More information about the grass-user mailing list