[GRASS-user] aggregating or totaling values by patch size

Hamish hamish_b at yahoo.com
Thu Jan 27 18:25:27 EST 2011


Janet wrote:
> i have 30m cell areas where i have a value for each cell
> representing a particular landscape characteristic (i.e.
> biomass)
> i want to find the total of those value (biomass) by 800m
> cells, i.e. what the total biomass is by 800m cells rather
> than by each 30m cell.
>
> does anyone know how to aggregate the 30m up to 800m?
> 
> i have created a 800m cell map - which i think i can use as the
> base map with r.average to get the average values from the 30m
> cover map, but i don't know how to get a total rather than an
> average.

try 
g.region rast=30m_biomass_map
g.region res=800
r.resamp.stats method=sum input=30m_biomass_map output=800m_biomass_map

actually that gets you slightly less than 800m cells, as 800 is
not an exact multiple of 30. by default GRASS compromises on
the resolution not the bounds. if 800m isn't a hard requirement,
you might try 900m instead,
 g.region rast=30m_biomass_map
 g.region -a res=900

(so aggregated 30x30 blocks of 30m cells)

if the old+new grids do not align exactly you may get the case
where the 30m cells along the edges are counted twice or not at
all. do test with r.univar to make sure that the overall "sum:"
of both the 30m (run at g.region 30m res) and 800, (run at
g.region 800m res) are identical.

900m grid cells which are not fully covered by the underlying 30m
map will have lesser sum values than their neighbors who are
fully covered by input data.


Hamish



      


More information about the grass-user mailing list