[GRASSweb-list]markus: web/grass51/tutorial examples.html,1.13,1.14

grass at intevation.de grass at intevation.de
Sun Feb 9 15:07:44 EST 2003

Author: markus

Update of /grassrepository/web/grass51/tutorial
In directory doto:/tmp/cvs-serv1651

Modified Files:
Log Message:
vector network example added

Index: examples.html
RCS file: /grassrepository/web/grass51/tutorial/examples.html,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -d -r1.13 -r1.14
--- examples.html	8 Feb 2003 21:32:38 -0000	1.13
+++ examples.html	9 Feb 2003 20:07:42 -0000	1.14
@@ -59,7 +59,7 @@
 <li><a href="#postgismapserver">Example: Writing the GRASS 5.0 Spearfish
    'streams' map into PostGIS for MapServer</a>
-<li><a href="shortestpath">Example: shortest path vector networking with
+<li><a href="#shortestpath">Example: shortest path vector networking with
@@ -690,13 +690,53 @@
 <DIV ALIGN=right><a href="#toc">[UP]</a></DIV>
-The first module based on that library is d.path:
-http://mpa.itc.it/radim/g51/d.path.jpg which uses for costs either line
-lengths, or costs saved as attributes in database (supports costs for both
-arcs and nodes), for example (g51-test):
+[for this exercise we use the Spearfish data set from the GRASS web site]
+A module based on the DGLib vector network library is 'd.path' (see <a
+href="http://mpa.itc.it/radim/g51/d.path.jpg">screenshot</a> which
+calculates shortest path on a vector network map. Traveling costs may be
+either line lengths, or costs saved as attributes in a database table
+(supported are cost assignments for both arcs and nodes). 
+<P> We want to use the 'roads' map of the Spearfish demo location (if
+needed, convert to 5.1 format with 'v.convert'). A simple example
+is to use the vector length as costs:
 <div class="code"><pre>
-d.path map=net nfield=2 ncol=cost afield=1 afcol=fcost abcol=bcost
+d.vect roads
+d.path map=roads
+More realistic shortest path queries may consider the maximum speed
+according to the road type. If desired to use different traveling costs for
+the two directions of a road, forward and backward costs are read from two
+different table columns. In our example we simply assume the same costs
+(same table column) for both directions. Node that you have to hit a node
+with the mouse in the GRASS monitor to select start/end point when
+using d.path.
+As the column 'travelcost' is not yet present in the table 'road' we can use
+StarOffice or OpenOffice to add it (see <a href=attrib_storage>here</a>).
+The we can continue and insert values according to the road type (be sure to
+quote strings when using for where statement):
+<div class="code"><pre>
+echo "select * from roads" | db.select
+... shows the travelcost column filled with 0.0.
+<div class="code"><pre>
+echo "update roads set travelcost=5 where cat=1" | db.execute
+echo "update roads set travelcost=20 where cat=2" | db.execute
+echo "update roads set travelcost=40 where cat=3" | db.execute
+echo "update roads set travelcost=60 where cat=4" | db.execute
+echo "update roads set travelcost=80 where cat=5" | db.execute
+echo "select * from roads" | db.select
+<div class="code"><pre>
+d.path map=roads afcol=travelcost abcol=travelcost

More information about the grass-web mailing list