<br><font size=2 face="sans-serif">Dear all,</font><br><br><font size=2 face="sans-serif">I am a new person to grass and am having
some problems with running a simple network analysis. If anybody can help
me it would be greatly appreciated. &nbsp;I am running grass 6.0 on debian.</font><br><font size=2 face="sans-serif">I have imported a shapefile representing
5km grid polygons across a large area. I have also imported a road shapefile
within this grid. And have imported a point shapefile with town locations
close to this road (network).</font><br><br><font size=2 face="sans-serif">What I would like to do for each centroid
of my 5km grid polygon layer is to calculate the nearest straight line
distance to the road feature. Once having calculated this distance - calculate
the distance along the road network to each town. Below is my attempt at
doing this. Any help/suggestions on improvement would be greatly appreciated.</font><br><br><font size=2 face="sans-serif">I am having problems making sure that
my town locations are on my road network and that the road network is complete.
I think that the road network is made up of line segments that are not
quite connected so I have tried v.clean to &quot;buffer the roads toegther&quot;.
Any suggestions on how to ensure that the lines are connected would be
greatly appreciated. The following are a list of commands that I am currently
using. My problem is that my network is not connected.</font><br><br><font size=2 face="Courier New">#v.in.ogr dsn=/home/andrew/rast.shp
output=rast min_area=0.0001 snap=-1</font><br><font size=2 face="Courier New">#v.in.ogr dsn=/home/andrew/road_seg.shp
output=road_seg min_area=0.0001 snap=-1 &nbsp;</font><br><font size=2 face="Courier New">#v.in.ogr dsn=/home/andrew/towns.shp
output=towns min_area=0.0001 snap=-1 </font><br><br><font size=2 face="sans-serif">I then try and convert the road segments
into connected lines </font><br><font size=2 face="Courier New">v.build.polylines input=road_seg output=road
</font><br><br><font size=2 face="sans-serif">I then try and intersect the towns and
the roads together </font><br><font size=2 face="Courier New">v.patch in=road,towns out=road_towns</font><br><br><font size=2 face="sans-serif">I then connect the towns and the roads</font><br><font size=2 face="Courier New">v.distance -p from=towns to=road output=road_towns_connect
upload=dist column=dist</font><br><br><font size=2 face="Courier New">#patch connecting line with roads and
towns</font><br><font size=2 face="Courier New">v.patch in=road_towns_connect,road_towns
out=pre_network_road_towns</font><br><font size=2 face="Courier New">v.db.connect road_towns dr=dbf data='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
table=road layer=1 key=cat</font><br><font size=2 face="Courier New">v.db.connect road_towns dr=dbf data='$GISDBASE/$LOCATION_NAME/$MAPSET/dbf/'
table=towns layer=2 key=cat</font><br><font size=2 face="Courier New">v.clean in=pre_network_road_towns out=network_road_towns
tool=break,snap</font><br><br><font size=2 face="Courier New">#add columns to rast polygon</font><br><font size=2 face="Courier New">echo &quot;ALTER TABLE rast ADD COLUMN
from_cat integer&quot; | db.execute</font><br><font size=2 face="Courier New">echo &quot;ALTER TABLE rast ADD COLUMN
dist double&quot; | db.execute</font><br><font size=2 face="Courier New">echo &quot;ALTER TABLE rast ADD COLUMN
to_x double&quot; | db.execute</font><br><font size=2 face="Courier New">echo &quot;ALTER TABLE rast ADD COLUMN
to_y double&quot; | db.execute</font><br><br><font size=2 face="Courier New">#need to run distance command</font><br><font size=2 face="Courier New">v.distance from=rast to=network_road_towns
from_type=centroid to_type=line from_layer=1 to_layer=1 dmax=-1 upload=cat,dist,to_x,to_y
column=from_cat,dist,to_x,to_y </font><br><br><font size=2 face="Courier New">#spit out to_x to_y coordinates of
intersection with network_towns_points</font><br><font size=2 face="Courier New">v.db.select map=rast layer=1 fs=&quot;|&quot;
-c &gt; xy_info_on_network</font><br><font size=2 face="Courier New">#spit x and y corrdinates of intersection
to a flatfile</font><br><font size=2 face="Courier New">awk &lt; xy_info_on_network -F&quot;|&quot;
'{ print $9,$10}' &gt; xy_on_network</font><br><font size=2 face="Courier New">#remove duplicates in file (I think
there are ??? points in the intersection)</font><br><font size=2 face="Courier New">sort xy_on_network &gt; xy_on_network_sort</font><br><font size=2 face="Courier New">uniq xy_on_network_sort &gt; xy_on_network_uniq</font><br><font size=2 face="Courier New">v.out.ascii input=towns output=xy_towns
format=point </font><br><br><br><br><font size=2 face="sans-serif">I then sucked the points of intersection
with the road network (xy_on_network_uniw) and the town locations &nbsp;(xy_towns)
into a perl script and spat out a big file that looked like this to loop
through each raster centroid intersection with the network and the location
of the town.</font><br><br><font size=2 face="sans-serif">echo &quot;1 574705.304072 9192756.736556
574705.30421218 9192756.73643771 &quot; | v.net.path network_road_points
&nbsp;out=mypath nlayer=1</font><br><font size=2 face="sans-serif">v.db.select map=mypath layer=1 fs='|'
&gt;&gt;fun</font><br><font size=2 face="sans-serif">g.remove vect=mypath</font><br><font size=2 face="sans-serif">echo &quot;2 574705.304212 9192756.736438
574705.30421218 9192756.73643771 &quot; | v.net.path network_road_points
&nbsp;out=mypath nlayer=1</font><br><font size=2 face="sans-serif">v.db.select map=mypath layer=1 fs='|'
&gt;&gt;fun</font><br><font size=2 face="sans-serif">g.remove vect=mypath</font><br><font size=2 face="sans-serif">...</font><br><font size=2 face="sans-serif">...</font><br><font size=2 face="sans-serif">...</font><br><br><font size=2 face="sans-serif">when I run this i get errors (on some
but not all v.net.path calls) basically saying that the node cannot be
found and reports a very big distance as a default. I have started to look
at the network and i think it is because I havent closed it properly. Any
help with regard to this. Also im thinking that it may be the accuracy
of the xy locations in ascii dumps. Im not sure if I could use node id's
and that would be better. Again any suggestions would be appreciated.</font><br><br><font size=2 face="sans-serif">cheers</font><br><br><font size=2 face="sans-serif">Andy</font><br><br><br><BR>
This email and any files transmitted with it are confidential, may be legally privileged and are intended solely for the use of the individual or entity to whom they are addressed. If you are not the intended recipient, you are hereby notified that any use, distribution, or reproduction of the contents of this email is strictly prohibited and may be unlawful. If you are not the intended recipient, please notify the sender by return email and destroy all copies of the original message including any attachments thereto. <BR>
Thank you.<BR>