[GRASS-dev] Creating / reading in random sample of raster values in Python script

Luca Delucchi lucadeluge at gmail.com
Sat Mar 25 12:21:17 PDT 2017


Il 25/mar/2017 20:07, "Paulo van Breugel" <p.vanbreugel at gmail.com> ha
scritto:

Hi,


Hi,


For a script I am working on, I am looking for a way to select a X number
of raster cells and their values into a numpy array. I can create a layer
with r.random, and read in that layer into a numpy array, but I rather
avoid having to read in the whole raster layer. I can also from within the
script run r.random  to generate a raster layer, r.stats to export the
resulting raster layer as a text file (with n flag), and than read in the
text file in Python. But I wonder if there is not a more direct way to
accomplish this..


You can read col and row from GRASS Region and use random python function
to calculate random x and y and later query a pygrass raster object


Cheers,

Paulo


Cheers
Luca
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-dev/attachments/20170325/6fed0799/attachment.html>


More information about the grass-dev mailing list