[GRASS-user] Trying to correct river network

Pankaj Kr Sharma pkscwc at gmail.com
Wed Oct 19 12:38:37 EDT 2011


Dear friends,

I derived stream network from r.watershed and converted it to vector.

I found that there are a number of small lines. And they are not merging
into long lines.

Reason: Some line segments have different directions.

Now, in  a river network direction should be from upstream to downstream.

i.e. at every junction, there should be exactly and only one start point and
other points should be end points.

I utilized this algorithm and wrote this script.

Initially, it gave syntax errors.

Now , there are no errors but no results either.

script
---------
elcat=4907;
for j in $elcat
do
cats=`echo "select cat from gis_schema.riy3 where start_long=(select
start_long from gis_schema.riy3 where cat=$elcat) and start_lat=(select
start_lat from gis_schema.riy3 where cat=$elcat) and cat <> $elcat; " |
db.select -c;`
for i in $cats
do
v.edit  map=riy3 at work layer=1 tool=flip cats=$cats;
sl=`echo "select start_long from gis_schema.riy3 where cat=$cats;" |
db.select -c;`
slat=`echo "select start_lat from gis_schema.riy3 where cat=$cats;" |
db.select -c;`
el=`echo "select end_long from gis_schema.riy3 where cat=$cats;" | db.select
-c;`
elat=`echo "select end_lat from gis_schema.riy3 where cat=$cats;" |
db.select -c;`
v.db.update  map=riy3 at work layer=1 column=start_long value=$el
where="cat=$cats";
v.db.update  map=riy3 at work layer=1 column=start_lat value=$elat
where="cat=$cats";
v.db.update  map=riy3 at work layer=1 column=end_long value=$sl
where="cat=$cats";
v.db.update  map=riy3 at work layer=1 column=end_lat value=$slat
where="cat=$cats";
done
elcat=`echo "select cat from gis_schema.riy3 where end_long=(select
start_long from gis_schema.riy3 where cat=$elcat) and end_lat=(select
start_lat from gis_schema.riy3 where cat=$elcat); " | db.select -c ;`
done
--------------
end of script

I ran this from grass command shell.

It ends silently.

Can someone help please.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.osgeo.org/pipermail/grass-user/attachments/20111019/f4448f7c/attachment.html


More information about the grass-user mailing list