[GRASS-user] Create random raster map with sum of cells == N
Johannes Radinger
johannesradinger at gmail.com
Mon Sep 9 02:07:51 PDT 2013
Hi Rainer,
I don't know of any standard GRASS tool that performs such tasks.
However I had a similar task, also an ecological topic and it was about
the redistribution of fish according to a dispersal kernel. So in my case
a number of fish (n_individuals) should be randomly distributed over a
raster map, but in my case with varying probabilities (used as weighting
factor) in the landscape.
I solved that with the python/array interface of GRASS, in detail with a
random multinomial approach of numpy:
# Import Python modules
import grass.script.array as garray
import numpy
# Probability map, varying probability over the landscape, used as
weighting factor
probmap = garray.array()
probmap.read("probmap")
# Output, redistributed individuals (n=500)
outputmap = garray.array()
n_individuals=500
outputmap[...] = numpy.random.multinomial(n_individuals,
(probmap/numpy.sum(probmap)).flat, size=1).reshape(probmap.shape)
outputmap.write("outputmap")
This approach is also implemented in the newest version of the GRASS-GIS
addon r.fidimo (GRASS70), which
is a fish dispersal model for river networks.
So maybe that approach helps you!
Best,
Johannes
On Fri, Sep 6, 2013 at 1:17 PM, Rainer M Krug <Rainer at krugs.de> wrote:
> Hi
>
> I am writing a simulation of dispersal, and one possible dispersal
> approach is to distribute a certain number of seeds N randomly in the
> landscape.
>
> Therefore I would like to generate a random raster map with the sum of
> all cells equals to N. Is there a way of doing this easily in GRASS?
>
> At the moment, I am using an R function, which distributes the seeds,
> but due to computational time considerations, I would like to move it to
> GRASS.
>
> Thanks,
>
> Rainer
>
>
> --
> Rainer M. Krug
>
> email: RMKrug<at>gmail<dot>com
>
> _______________________________________________
> grass-user mailing list
> grass-user at lists.osgeo.org
> http://lists.osgeo.org/mailman/listinfo/grass-user
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20130909/87a68883/attachment.html>
More information about the grass-user
mailing list