[GRASS-user] sampling points in a grid

Markus Neteler neteler at osgeo.org
Tue Feb 17 08:30:48 PST 2015


On Tue, Feb 17, 2015 at 4:49 PM, Margherita Di Leo <diregola at gmail.com> wrote:
> Hi,
>
> I have a vector of points. According to a regular grid, I need to (randomly)
> sample a certain number n of these points in each cell of the grid. Such
> number n is given in a column of the attribute table of the grid. How would
> you do this?

With a small script this should be doable:
- generate the grid as polygons (v.mkgrid)
- loop over each polygon
     - fetch category number or v.extract
     - fetch corresponding number of points to be created from DB
     - v.random, using the current grid polygon for restricted creation feature
        http://grass.osgeo.org/grass70/manuals/v.random.html#restriction-to-vector-areas
     - save point map
- patch all point maps into single resulting map
- remove single point maps

Something like this...

Markus


More information about the grass-user mailing list