Provided by: grass-doc_6.4.3-3_all

**NAME**

v.net.distance- Computes shortest distance via the network between the given sets of features. Finds the shortest paths from a feature 'to' to every feature 'from' and various information about this realtion are uploaded to the attribute table.

**KEYWORDS**

vector, network, shortest path

**SYNOPSIS**

v.net.distancev.net.distancehelpv.net.distance[-g]input=nameoutput=name[from_layer=integer] [from_cats=range] [from_where=sql_query] [to_layer=integer] [to_cats=range] [to_where=sql_query] [to_type=string[,string,...]]afcolumn=name[abcolumn=name] [--overwrite] [--verbose] [--quiet]Flags:-gUse geodesic calculation for longitude-latitude locations--overwriteAllow output files to overwrite existing files--verboseVerbose module output--quietQuiet module outputParameters:input=nameName of input vector mapoutput=nameName for output vector mapfrom_layer=integerFrom layer number or name A single vector map can be connected to multiple database tables. This number determines which table to use. Default:1from_cats=rangeFrom category values Example: 1,3,7-9,13from_where=sql_queryFrom WHERE conditions of SQL statement without 'where' keyword Example: income = 10000to_layer=integerLayer number To layer number or name Default:1to_cats=rangeTo category values Example: 1,3,7-9,13to_where=sql_queryTo WHERE conditions of SQL statement without 'where' keyword Example: income = 10000to_type=string[,string,...] To feature type Options:point,line,boundaryDefault:pointafcolumn=nameArc forward/both direction(s) cost columnabcolumn=nameArc backward direction cost column

**DESCRIPTION**

v.net.distancefinds the nearest element in settofor every point in setfrom.

**NOTES**

These two sets are given by the respectivelayer,whereandcatsparameters. The type oftofeatures is specified byto_typeparameter. Allfromfeatures arepoints. A table is linked tooutputmap containing various information about the relation. More specifically, the table has three columns:cat,tcatanddiststoring category of eachfromfeature, category of the nearesttofeature and the distance between them respectively. Furthemore,outputmap contains the shorest path between eachcat,tcatpair. Each path consist of several lines. If a line is on the shorest path from a point then the category of this point is assigned to the line. Note that every line may contain more than one category value since a single line may be on the shortest path for more than onefromfeature. And so the shortest paths can be easily obtained by querying lines with corresponding category number. The costs of arcs in forward and backward direction are specified byafcolumnandabcolumncolumns respectively. Ifabcolumnis not given, the same cost is used in both directions.v.net.distancewill not work if you are trying to find the nearest neighbors within a group of nodes, i.e. wheretoandfromare the same set of nodes, as the closest node will be the node itself and the result will be zero-length paths. In order to find nearest neighbors within a group of nodes, you can either loop through each node astoand all other nodes asfromor create a complete distance matrix with v.net.allpairs and select the lowest non-zero distance for each node.

**EXAMPLES**

Find shortest path and distance from every school to the nearest hospital and show path from school number one. v.net.distance input=city output=nearest from_where="type=school" \ to_where="type=hospital" afcolumn=SHAPE_LEN d.vect nearest cats=1

**SEE** **ALSO**

v.net.path,v.net.allpairs,v.net.distance,v.net.alloc

**AUTHORS**

Daniel Bundala, Google Summer of Code 2009, Student Wolf Bergenheim, MentorLastchanged:$Date:2013-05-2313:01:55-0700(Thu,23May2013)$Full index © 2003-2013 GRASS Development Team