[GRASS-user] Computing histograms inline with mapcalc?
Shaun Walbridge
walbridge at nceas.ucsb.edu
Fri Jul 13 19:07:30 EDT 2007
Hi All,
We're looking at running a Monte Carlo simulation with our GRASS data,
and one step I'd like to simplify is making histograms. Currently we
use R, but given that our input rasters have millions of cells, it's
time consuming. I was thinking that we might be able to use GRASS
directly, since we're just doing many r.mapcalc calls.
I see histogram.c, and ideally I'd like to just roll a custom r.mapcalc
which adds its output to a histogram function, then write it out at the
end of the program. My C chops are poor, but I'm imagining something as
simple (in Python) as:
hist = {}
values = [0.1, 0.1, 0.2, 3, 5, 3, 0.1, 0.2, 3, 0.1, 0.1]
for v in values:
if hist.has_key(v):
hist[v] += 1
else:
hist[v] = 1
What would be my best bet for creating this histogram? Is hacking up my
own mapcalc function feasible?
thanks for the guidance,
Shaun Walbridge
More information about the grass-user
mailing list