[GRASSLIST:8475] Re: extracting the value of a raster cell
Hamish
hamish_nospam at yahoo.com
Mon Oct 3 20:30:28 EDT 2005
> > Can you explain what is meant by the "spatial mean" calculation?
>
> A spatial mean is simply the mean value of series of numbers that
> also has a location in coordinate space. For example, imagine the
> population of each state in the continental US. You can easily
> calculate the mean population size, right? Ok, now WHERE is the mean
> population on the map of the US? It's actually simple to calculate.
> The spatial mean is really just a weighted average using the
> coordinates of the center of each state. So, to calculate the
> spatial mean for a raster map, you need the value and coordinate pair
> for each cell. Hence, my original request.
Thanks for explaining that. So the "answer" is a spatial coordinate at
the "center of mass"; not a number in units of the attribute, correct?
No, I don't think anything exists in grass to do this, but probably the
most efficient way to get the values out using existing tools is:
(Short of writing a custom C module that is)
r.stats -g input=raster_map
alternatively,
r.to.vect(points) + v.out.ascii.db.
v.out.ascii.db is available at the GRASS Wiki add-ons page, I've not
tested it for a dataset as large as r.to.vect(points) will generate.
I'd be interested to know if it works.
But who knows, maybe there's a smart way to use r.cost + r.mapcalc in an
inverse way to find a maxima who's position could be queried.
Hamish
More information about the grass-user
mailing list