[GRASSLIST:4] Re: Creating axis of a river

Hamish hamish_nospam at yahoo.com
Fri Mar 10 19:57:12 EST 2006


> I got a 3d vector file made of 2 lines which describes the boundairs
> of a river... I need to create the mid-line between them.. (the axis
> of the river)..
> Any ideas?

There is probably a better way, but one method I have recently used:

g.region res=10 -a

v.category in=Coastline out=Coastline_bdy_cat op=add type=boundary step=0
v.extract in=Coastline_bdy_cat out=Coastline_bdy type=boundary
v.type in=Coastline_bdy out=Coastline_line type=boundary,line
v.to.rast in=Coastline_line out=Coastline_line use=val

# make sure starting points are no lost in NULL
r.grow in=regional_bound out=regional_bound_grown1 old=1 new=1

r.cost -v -k input=regional_bound_grown1 \
  output="cost_to_coast_10m" start_rast="Coastline_line" \
  max_cost=1000 percent_memory=40

g.copy Sea_mask,MASK

r.mapcalc 'dist_to_coast = cost_to_coast_10m * 10'

g.remove MASK

#extract the "ridge line", see also 'r.param.scale param=feature'
r.param.scale in="dist_to_coast" out=dist_to_coast.slope_rps7 \
  size=7 param="slope"

r.mapcalc 'center_line.to35d = if(dist_to_coast.slope_rps7 <= 35, \
  dist_to_coast.slope_rps7all, null())

r.thin in=center_line.to35d out=center_line.to35d_thinned

r.to.vect center_line.to35d_thinned feature=line


Hamish




More information about the grass-user mailing list