[GRASS-user] v.random, X points per category

Hello,

I've got a rastermap (river-network) with differnent category values representing the single sections. Now I want to create points, excactly one point per section. I'd be best if the point is approximately in the middle of each the raster-line, but a random value would be already okay.
With v.random its possible to set the number of points which should be created, but is it somehow possible to tell GRASS GIS to create only one (random) point per raster category?

thanks
Johannes

On Mon, Jan 31, 2011 at 4:49 PM, Johannes Radinger <JRadinger@gmx.at> wrote:

Hello,

I've got a rastermap (river-network) with differnent category values
representing the single sections. Now I want to create points, excactly one
point per section. I'd be best if the point is approximately in the middle
of each the raster-line, but a random value would be already okay.

What about (untested):
- convert to vector
- upload the length to each vector as attribute with v.to.db
  or use v.report line option=length units=meters
- loop over all vectors
   - extract one vector
   - fetch length, divide by 2
   - use v.to.points -n in=line out=line_node dmax=half_length
   - extract the first one (cat=1) with v.extract

Cheers
Markus