<div dir="ltr">Maybe you can use a database selection approach for example in sqlite.<div>First update your points with your grid cell ID and then randomly select</div><div>7 rows from the selection where the grid cell ID == 42.</div><div><br></div><div>In sqlite there exists the function random(). Here you can find</div><div>an approach to select random rows from a sqlite table:</div><div><a href="http://stackoverflow.com/questions/2279706/select-random-row-from-an-sqlite-table">http://stackoverflow.com/questions/2279706/select-random-row-from-an-sqlite-table</a><br></div><div><br></div><div>I have not tested that approach, but maybe worth a try...</div><div><br></div><div>/Johannes</div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Feb 18, 2015 at 11:55 AM, Margherita Di Leo <span dir="ltr"><<a href="mailto:diregola@gmail.com" target="_blank">diregola@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr"><br><div class="gmail_extra"><br><div class="gmail_quote"><span class="">On Tue, Feb 17, 2015 at 5:30 PM, Markus Neteler <span dir="ltr"><<a href="mailto:neteler@osgeo.org" target="_blank">neteler@osgeo.org</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><span>On Tue, Feb 17, 2015 at 4:49 PM, Margherita Di Leo <<a href="mailto:diregola@gmail.com" target="_blank">diregola@gmail.com</a>> wrote:<br>
</span><span>> Hi,<br>
><br>
> I have a vector of points. According to a regular grid, I need to (randomly)<br>
> sample a certain number n of these points in each cell of the grid. Such<br>
> number n is given in a column of the attribute table of the grid. How would<br>
> you do this?<br>
<br>
</span>With a small script this should be doable:<br>
- generate the grid as polygons (v.mkgrid)<br>
- loop over each polygon<br>
- fetch category number or v.extract<br>
- fetch corresponding number of points to be created from DB<br>
- v.random, using the current grid polygon for restricted creation feature<br>
<a href="http://grass.osgeo.org/grass70/manuals/v.random.html#restriction-to-vector-areas" target="_blank">http://grass.osgeo.org/grass70/manuals/v.random.html#restriction-to-vector-areas</a></blockquote><div><br></div></span><div>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.</div><span class=""><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><br>
- save point map<br>
- patch all point maps into single resulting map<br>
- remove single point maps<br>
<br>
Something like this...<br>
<span><font color="#888888"><br>
Markus<br>
</font></span></blockquote></span></div><br><br clear="all"><span class=""><div><br></div>-- <br><div><div dir="ltr"><div><font color="#666666">Best regards,</font></div><div><font color="#666666"><br></font></div><div><font color="#666666">Dr. Margherita DI LEO </font></div><div><span style="color:rgb(102,102,102);font-family:arial;font-size:small">Scientific / technical project officer</span><br></div><div><font color="#666666"><br></font></div><div><font color="#666666">European Commission - DG JRC </font></div><div><font color="#666666">Institute for Environment and Sustainability (IES)</font></div><div><font color="#666666">Via Fermi, 2749</font></div><div><font color="#666666">I-21027 Ispra (VA) - Italy - TP 261</font></div><div><font color="#666666"> </font></div><div><font color="#666666">Tel. +39 0332 78 3600 </font></div><div><font color="#666666"><a href="mailto:margherita.di-leo@jrc.ec.europa.eu" target="_blank">margherita.di-leo@jrc.ec.europa.eu</a></font></div><div><font color="#666666"><br></font></div><div><font color="#666666">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.</font></div></div></div>
</span></div></div>
<br>_______________________________________________<br>
grass-user mailing list<br>
<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a><br>
<a href="http://lists.osgeo.org/mailman/listinfo/grass-user" target="_blank">http://lists.osgeo.org/mailman/listinfo/grass-user</a><br></blockquote></div><br></div>