sourCEntral - mobile manpages

pdf

v.distance

NAME

v.distance

DESCRIPTION

v.distance finds features from one vector (from=) feature to another vector (to=) nearest feature. Various information about relation (distance, ...) may be uploaded to attribute table attached to first vector map or printed to ’stdout’. A new vector map may be created where lines connecting nearest points on features are written.

EXAMPLES

1) Find nearest lines in vector map ln for points from vector map pnt within the given threshold and write related line categories to column linecat in attribute table attached to vector map pnt:
v.distance from=pnt to=ln upload=cat column=linecat

2) For each point from vector map pnt find nearest area from map ar within the given threshold and write the related area categories to column areacat in attribute table attached to vector map pnt. In case a point falls into a polygon area, the distance is zero:
v.distance from=pnt to=ar upload=cat column=areacat

3) Create a new vector map which contains lines connecting nearest features of maps pnt and map ln. The resulting vector map can be used for example to connect points to a network as needed for network analysis:
v.distance -p from=pnt to=ln out=connections upload=dist column=dist

4) Query information from selected point(s). v.distance takes points from vector as input instead of stdin. First new vector map with query points, has to be created, then the map can be analysed:

Create query map (if not present):
echo "123456|654321|1" | v.in.ascii output=pnt

Find nearest features:
v.distance from=pnt to=map_to_query upload=cat col=somecol -p

5) Point-in-polygon: Find area from vector map ar for each point from vector map pnt in which the individual point falls into and write the related area categories to column areacat into attribute table attached to vector map pnt:
v.distance from=pnt to=ar dmax=0 upload=cat column=areacat

6) Univariate statistics on results: Create a vector map containing connecting lines and investigate mean distance to targets.
An alternative solution is to use the v.distance upload=dist option to upload distances into the bugs vector directly, then run v.univar on that. Also note you can upload two columns at a time.
e.g. v.distance upload=cat,dist column=nearest_id,dist_to_nr
# create working copy
g.copy vect=bugsites,bugs
# add new attribute column to hold nearest archsite category number
v.db.addcol map=bugs column="nrst_arch INTEGER"
v.distance from=bugs to=archsites to_type=point upload=to_attr \
to_column=cat column=nrst_arch out=vdistance_vectors_raw
# we need to give the lines category numbers, create a table, and create
# a column in that table to hold the distance data.
v.category vdistance_vectors_raw out=vdistance_vectors type=line op=add
g.remove v=vdistance_vectors_raw
v.db.addtable map=vdistance_vectors column="length DOUBLE"
v.to.db map=vdistance_vectors option=length column=length
# calculcate statistics. Use v.univar.sh for extended statistics.
v.univar vdistance_vectors column=length

NOTES

If a nearest feature does not have a category, column is updated to null. This is true also for areas, which means for example, that if point is in island (area WITHOUT category), v.distance does not search for nearest area WITH category, island is identified as nearest and category updated to null.

The upload column(s) must already exist. Create one with v.db.addcol.

SEE ALSO

r.distance, v.db.addcol, v.what.vect

AUTHOR

Janne Soimasuo 1994, Finland
University of Joensuu, Faculty of Forestry, Finland

5.0 cmd line coordinates support: Markus Neteler, ITC-irst, Trento, Italy

5.1 update Radim Blazek, ITC-irst, Trento, Italy

Last changed: $Date: 2006/03/30 11:40:14 $

Full index

pdf