DESCRIPTION loads vector map features or metrics into a database table, or prints them (or the SQL queries used to obtain them) in a form of a human-readable report. For uploaded/printed category values '-1' is used for 'no category' and 'null'/'-' if category cannot be found or multiple categories were found. For line azimuths '-1' is used for closed lines (start equals end).


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

Feet and acre units are always reported in their common versions (i.e. the International Foot, exactly 5280 feet in a mile), even when the location's standard map unit is the US Survey foot.

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

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

Line azimuth is calculated as angle from the North direction to the line endnode direction at the line statnode. By default it's reported in decimal degrees (0-360, CW) but it also may be repored in radians with unit=radians. Azimuth value -1 is used to report closed line with it's startnode and endnode being in same place. Azimuth values make sense only if every vector line has only one entry in database (unique CAT value).

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.

Uploading the vector map attributes to a database requires a table attached to a given input vector layer. The print only (-p) mode doesn't require a table. Use db.execute or v.db.addtable to create a table if needed.

Updating the table has to be done column-wise. The column must be present in the table, except when using the print only (-p) mode. Use db.execute or v.db.addcol to add new columns if needed.


Updating attribute tables

Upload category numbers to attribute table (used for new map): map=soils type=centroid option=cat

Upload polygon areas to corresponding centroid record in the attribute table: map=soils type=centroid 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): map=roads option=length type=line col=linelength units=me

Upload x and y coordinates from vector geometry to attribute table: map=pointsmap option=coor col=x,y

Upload x, y and z coordinates from vector geometry to attribute table: map=pointsmap option=coor col=x,y,z

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

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

Upload category numbers of left and right area, to an attribute table of boundaries common for the areas:

# add categories for boundaries of the input vector map, in layer 2:
v.category soils out=mysoils layer=2 type=boundary option=add
# add a table with columns named "left" and "right" to layer 2 of the input
# vector map:
v.db.addtable mysoils layer=2 col="left integer,right integer"
# upload categories of left and right areas: mysoils option=sides col=left,right layer=2
# display the result: mysoils layer=2

Compute DL, the Fractal Dimension (Mandelbrot, 1982), of the boundary defining a polygon based on the formula:
D = 2 * (log perimeter) / (log area):

g.copy vect=soils,mysoils
v.db.addcol mysoils col="d double precision" mysoils option=fd column="d"

g.region vect=mysoils res=50 in=mysoils out=soils_fd type=area use=attr column=d
r.colors map=soils_fd color=gyr

d.mon x0
d.rast.leg soils_fd
d.vect mysoils type=boundary

Printing reports

Report x,y,z coordinates of points in the input vector map: -p bugsites option=coor type=point
Report all area sizes of the input vector map: -p soils option=area type=boundary units=h

Report all area sizes of the input vector map, in hectares, sorted by category number (requires GNU sort utility installed): -p soils option=area type=boundary units=h | sort -n

Report all line lengths of the input vector map, in kilometers: -p roads option=length type=line units=k

Report number of features for each category in the input vector map: -p roads option=count type=line


d.what.vect, db.execute, v.category, v.db.addtable, v.db.addcol, v.db.connect, v.distance,, v.univar, v.what


  • Mandelbrot, B. B. (1982). The fractal geometry of nature. New York: W. H. Freeman.
  • Xu, Y. F. & Sun, D. A. (2005). Geotechnique 55, No. 9, 691-695

    Radim Blazek, ITC-irst, Trento, Italy
    Line sinuousity implemented by Wolf Bergenheim

    Last changed: $Date$