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

Markus Neteler neteler at osgeo.org
Mon Jan 31 15:55:55 EST 2011

On Mon, Jan 31, 2011 at 4:49 PM, Johannes Radinger <JRadinger at 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


More information about the grass-user mailing list