DESCRIPTION

v.to.db is used to load vector map features or metrics into database fields.

NOTES

The units 'miles', 'feet', 'meters' and 'kilometers' are square for option=area.

When using option=coor on a vector area map, only coordinates of centroids with unique category will be reported.

When calculating perimeters in Latitude-Longitude locations, the geodesic distance between the vertices is used.

The column(s) given by the column option must already exist. Create one with v.db.addcol.

If the module is apparently slow and the map attributes are stored in an external DBMS such as PostgreSQL, it is highly recommended to create an index on the key (category) column.

EXAMPLES

Updating attribute tables

Note: Uploading of the attributes of a vector map to the DBMS has to be done column-wise. The column must be present in the table (use db.execute to add a new column if needed).

Upload category numbers to attribute table (used for new map):

v.to.db map=soils type=area option=cat

Upload area sizes of each polygon to attribute table:

v.to.db map=soils type=area option=area col=area_size unit=h

Upload line lengths (in meters) of each vector line to attribute table (use v.category in case of missing categories):

v.to.db map=roads option=length type=line col=linelength units=me

Upload x and y coordinates from vector geometry to attribute table:

v.to.db map=pointsmap option=coor col=x,y

Upload x, y and z coordinates from vector geometry to attribute table:

v.to.db map=pointsmap option=coor col=x,y,z

Transfer of attributes from character column (with numeric contents) to new integer column:

v.db.addcol usa_income_employment2002 col="FIPS_NUM integer"
v.to.db usa_income_employment2002 option=query col=FIPS_NUM qcol=STATE_FIPS

Upload category numbers of left/right polygons neighboring boundaries to attribute table:

# add boundary categories into geometry at layer 2:
v.category soils out=mysoils layer=2 type=boundary option=add
# add table with left/right column to layer 2:
v.db.addtable mysoils layer=2 col="left integer,right integer"
# upload categories of left/right polygons:
v.to.db mysoils option=sides col=left,right layer=2
# display the result:
v.db.select mysoils layer=2

Printing reports

Report all area sizes of a map:
v.to.db -p soils option=area type=boundary units=h

Report all area sizes of a map, sorted by category number:

v.to.db -p soils option=area type=boundary units=h | sort -n

Report all line lengths of a map:

v.to.db -p roads option=length type=line units=k

Report number of features for each category in map:

v.to.db -p roads option=count type=line

SEE ALSO

v.category, v.db.addtable, v.db.addcol, v.distance, v.what.vect

AUTHOR

Radim Blazek

Last changed: $Date$