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@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@work layer=1 column=start_long value=$el where=“cat=$cats”;
v.db.update map=riy3@work layer=1 column=start_lat value=$elat where=“cat=$cats”;
v.db.update map=riy3@work layer=1 column=end_long value=$sl where=“cat=$cats”;
v.db.update map=riy3@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.