[GRASS-user] Randomly select points from existing vector?
Hamish
hamish_b at yahoo.com
Tue Mar 11 18:25:33 EDT 2008
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
More information about the grass-user
mailing list