[GRASS-user] sampling points in a grid

Margherita Di Leo diregola at gmail.com
Wed Feb 18 02:55:58 PST 2015


On Tue, Feb 17, 2015 at 5:30 PM, Markus Neteler <neteler at osgeo.org> wrote:

> 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


Here lies the problem. I need to randomly pick points that are already
existing. Example: for grid cell that has ID 42, I have 50 points, and have
to randomly pick 7 out of these 50.

>
>      - save point map
> - patch all point maps into single resulting map
> - remove single point maps
>
> Something like this...
>
> Markus
>



-- 
Best regards,

Dr. Margherita DI LEO
Scientific / technical project officer

European Commission - DG JRC
Institute for Environment and Sustainability (IES)
Via Fermi, 2749
I-21027 Ispra (VA) - Italy - TP 261

Tel. +39 0332 78 3600
margherita.di-leo at jrc.ec.europa.eu

Disclaimer: The views expressed are purely those of the writer and may not
in any circumstance be regarded as stating an official position of the
European Commission.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/grass-user/attachments/20150218/156bbd4c/attachment.html>


More information about the grass-user mailing list