Dear friends,<br><br>I derived stream network from r.watershed and converted it to vector.<br><br><div class="gmail_quote">I found that there are a number of small lines. And they are not merging into long lines.<br><br>Reason: Some line segments have different directions.<br>
<br>Now, in  a river network direction should be from upstream to downstream.<br><br>i.e. at every junction, there should be exactly and only one start point and other points should be end points.<br><br>I utilized this algorithm and wrote this script.<br>
<br>Initially, it gave syntax errors.<br><br>Now , there are no errors but no results either.<br><br>script<br>---------<br>elcat=4907;<br>for j in $elcat<br>do<br>cats=`echo &quot;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 &lt;&gt; $elcat; &quot; | db.select -c;`<br>
for i in $cats<br>do<br>v.edit  map=riy3@work layer=1 tool=flip cats=$cats;<br>sl=`echo &quot;select start_long from gis_schema.riy3 where cat=$cats;&quot; | db.select -c;`<br>slat=`echo &quot;select start_lat from gis_schema.riy3 where cat=$cats;&quot; | db.select -c;`<br>
el=`echo &quot;select end_long from gis_schema.riy3 where cat=$cats;&quot; | db.select -c;`<br>elat=`echo &quot;select end_lat from gis_schema.riy3 where cat=$cats;&quot; | db.select -c;`<br>v.db.update  map=riy3@work layer=1 column=start_long value=$el  where=&quot;cat=$cats&quot;;<br>
v.db.update  map=riy3@work layer=1 column=start_lat value=$elat  where=&quot;cat=$cats&quot;;<br>v.db.update  map=riy3@work layer=1 column=end_long value=$sl  where=&quot;cat=$cats&quot;;<br>v.db.update  map=riy3@work layer=1 column=end_lat value=$slat  where=&quot;cat=$cats&quot;;<br>
done<br>elcat=`echo &quot;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); &quot; | db.select -c ;`<br>
done<br>--------------<br>end of script<br><br>I ran this from grass command shell.<br><br>It ends silently.<br><br>Can someone help please.<br></div><br>