1v.to.db(1)                    Grass User's Manual                   v.to.db(1)
2
3
4

NAME

6       v.to.db   -  Load  values  from vector to database. In uploaded/printed
7       category values '-1' is used for 'no category' and 'null'/'-' if  cate‐
8       gory cannot be found or multiple categories were found.
9

KEYWORDS

11       vector
12

SYNOPSIS

14       v.to.db
15       v.to.db help
16       v.to.db  [-psc]  map=name  [type=string[,string,...]]   [layer=integer]
17       [qlayer=integer]       option=string       [units=string]         [col‐
18       umn=string[,string,...]]   [qcolumn=string]
19
20   Flags:
21       -p  print only
22
23       -s  only print sql statements
24
25       -c  In print mode prints totals for options: length,area,count
26
27   Parameters:
28       map=name
29           Name of input vector map
30
31       type=string[,string,...]
32           Type  of  elements (for coor valid point/centroid, for length valid
33           line/boundary)   Options:   point,line,boundary,centroid   Default:
34           point,line,boundary,centroid
35
36       layer=integer
37           Layer number Default: 1
38
39       qlayer=integer
40           Query layer. Used by 'query' option.  Default: 1
41
42       option=string
43           Value      to      upload     Options:     cat,area,compact,perime‐
44           ter,length,count,coor,start,end,sides,query cat: insert new row for
45           each  category  if  doesn't exist yet area: area size compact: com‐
46           pactness of an area, calculated as compactness = perimeter /  (2  *
47           sqrt(PI  *  area))  perimeter:  perimeter length of an area length:
48           line length count: number of features for each category coor: point
49           coordinates, X,Y or X,Y,Z start: line/boundary starting point coor‐
50           dinates, X,Y or X,Y,Z end: line/boundary end point coordinates, X,Y
51           or  X,Y,Z  sides: categories of areas on the left and right side of
52           the boundary, 'qlayer' is used for area category query: result of a
53           database  query for all records of the geometry(or geometries) from
54           table specified by 'qlayer' option
55
56       units=string
57           mi(les),f(eet),me(ters),k(ilometers),a(cres),h(ectares)    Options:
58           mi,miles,f,feet,me,meters,k,kilometers,a,acres,h,hectares
59
60       column=string[,string,...]
61           column(s)
62
63       qcolumn=string
64           Query  column  used  for  'query'  option.  E.g. 'cat', 'count(*)',
65           'sum(val)'
66

DESCRIPTION

68       v.to.db loads vector map features or metrics into a database table,  or
69       prints  them  (or  the  SQL queries used to obtain them) in a form of a
70       human-readable report.
71

NOTES

73       The  units  miles,  feet,  meters  and  kilometers   are   square   for
74       option=area.
75
76       When  using  option=coor on a vector area map, only coordinates of cen‐
77       troids with unique category will be reported.
78
79       When calculating perimeters in Latitude-Longitude locations,  the  geo‐
80       desic distance between the vertices is used.
81
82       If  the  module is apparently slow and the map attributes are stored in
83       an external DBMS such as PostgreSQL, it is highly recommended to create
84       an index on the key (category) column.
85
86       Uploading  the  vector  map  attributes  to a database requires a table
87       attached to a given input  vector  layer.  The  print  only  (-p)  mode
88       doesn't  require  a  table. Use db.execute or v.db.addtable to create a
89       table if needed.
90
91       Updating the table has to be  done  column-wise.  The  column  must  be
92       present  in  the table, except when using the print only (-p) mode. Use
93       db.execute or v.db.addcol to add new columns if needed.
94

EXAMPLES

96   Updating attribute tables
97       Upload category numbers to attribute table (used for new map):
98
99       v.to.db map=soils type=area option=cat
100
101
102       Upload area sizes of each polygon to attribute table:
103
104       v.to.db map=soils type=area option=area col=area_size unit=h
105
106
107       Upload line lengths (in meters) of each vector line to attribute  table
108       (use v.category in case of missing categories):
109
110       v.to.db map=roads option=length type=line col=linelength units=me
111
112
113       Upload x and y coordinates from vector geometry to attribute table:
114
115       v.to.db map=pointsmap option=coor col=x,y
116
117
118       Upload x, y and z coordinates from vector geometry to attribute table:
119
120       v.to.db map=pointsmap option=coor col=x,y,z
121
122
123       Transfer of attributes from character column (with numeric contents) to
124       new integer column:
125
126       v.db.addcol usa_income_employment2002 col="FIPS_NUM integer"
127       v.to.db     usa_income_employment2002     option=query     col=FIPS_NUM
128       qcol=STATE_FIPS
129
130
131       Upload  category  numbers of left/right polygons neighboring boundaries
132       to attribute table:
133
134       # add boundary categories into geometry at layer 2:
135       v.category soils out=mysoils layer=2 type=boundary option=add
136       # add table with left/right column to layer 2:
137       v.db.addtable mysoils layer=2 col="left integer,right integer"
138       # upload categories of left/right polygons:
139       v.to.db mysoils option=sides col=left,right layer=2
140       # display the result:
141       v.db.select mysoils layer=2
142
143
144   Printing reports
145       Print x,y,z coordinates using dummy columns. The columns don't have  to
146       exist in the table for the features to be reported. Even a table is not
147       required:
148       v.to.db -p bugsites option=coor type=point column=dummy1,dummy2
149        Report all area sizes of a map:
150
151       v.to.db -p soils option=area type=boundary units=h
152
153
154       Report all area sizes of a map, sorted by category number:
155
156       v.to.db -p soils option=area type=boundary units=h | sort -n
157
158
159       Report all line lengths of a map:
160
161       v.to.db -p roads option=length type=line units=k
162
163
164       Report number of features for each category in map:
165
166       v.to.db -p roads option=count type=line
167
168

SEE ALSO

170        v.category v.db.addtable v.db.addcol v.db.connect  v.distance  db.exe‐
171       cute v.what d.what.vect
172

AUTHOR

174       Radim Blazek
175
176       Last changed: $Date: 2006/09/22 12:22:10 $
177
178       Full index
179
180
181
182GRASS 6.2.2                                                         v.to.db(1)
Impressum