Hi
Trying to select 10 points at random from an existing vector. Not sure how to do it other than v.kcv where I divide the 750 points into 75 partitions and grab one of those. Is there a more efficient way?
Thanks
Ken
Hi
Trying to select 10 points at random from an existing vector. Not sure how to do it other than v.kcv where I divide the 750 points into 75 partitions and grab one of those. Is there a more efficient way?
Thanks
Ken
Ken Nussear wrote:
Trying to select 10 points at random from an existing vector. Not
sure how to do it other than v.kcv where I divide the 750 points into
75 partitions and grab one of those. Is there a more efficient way?
Does the starting vector map contain points or areas, or ...?
for points, assuming cats are 1-750 you can use some program to
generate random numbers in the range of (1,750) and then use 'v.extract
list=' to grab them.
e.g. here's how to do it in Octave or Matlab:
round((rand(10,1) * (750-1)) + 1)
but there will be similar ways using R, awk, $RANDOM from a shell, etc.
here is one way to do it with awk:
seq 10 | awk 'BEGIN {srand()} {print int(rand()*(750-1)+1+0.5) }'
or
seq 10 | awk "BEGIN {srand($RANDOM)} {print int(rand()*(750-1)+1+0.5)
}"
for selecting 10 random points within a polygon, try v.random.cover
from the wiki addons or r.random with the vector option.
Hamish
____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs
On Tue, Mar 11, 2008 at 4:46 PM, Ken Nussear <knussear@mac.com> wrote:
Hi
Trying to select 10 points at random from an existing vector. Not sure how
to do it other than v.kcv where I divide the 750 points into 75 partitions
and grab one of those. Is there a more efficient way?
From >= GRASS 6.4 there is: v.extract:
v.extract help
...
random Number of random categories matching vector objects to extract
Best,
Markus (cleaning inbox)