1v.in.db(1) Grass User's Manual v.in.db(1)
2
3
4
6 v.in.db - Create new vector (points) from database table containing
7 coordinates.
8
10 vector, import
11
13 v.in.db
14 v.in.db help
15 v.in.db driver=string database=string table=string x=string y=string
16 [z=string] key=string [where=sql_query] output=name [--overwrite]
17
18 Flags:
19 --overwrite
20
21 Parameters:
22 driver=string
23 Input driver name Options: dbf,mysql,ogr,pg,sqlite,mesql,odbc
24
25 database=string
26 Input database name
27
28 table=string
29 Input table name
30
31 x=string
32 x column name
33
34 y=string
35 y column name
36
37 z=string
38 z column name
39
40 key=string
41 category column name
42
43 where=sql_query
44 WHERE conditions of SQL statement without 'where' keyword. (exam‐
45 ple: income = 10000)
46
47 output=name
48 Name for output vector map
49
51 v.in.db creates new vector (points) map from database table containing
52 coordinates.
53
55 1) Creating a map from PostgreSQL table:
56
57 v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
58 table=pat_stazioni x=east y=north z=quota key=id out‐
59 put=pat_stazioni
60
61
62 If an ID column is not not present in the PostgreSQL table, a new col‐
63 umn should be added. See pg driver page for detail.
64
65 2) Creating a map from PostGIS:
66 To extract coordinate values from PostGIS, functions have to be used:
67 v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
68 table=station x="x(geom)" y="y(geom)" z="z(geom)" key=id
69 out=meteostations
70
71
72 If an ID column is not not present in the PostgreSQL table, a new col‐
73 umn should be added. See pg driver page for detail.
74
75 3) Import of a points table (x, y, z) from DBF file to vector points map:
76
77 #create vector map from DBF table (here, 'idcol' contains unique row
78 IDs, 'z' is optional):
79 #the 'database' parameter is the directory where the DBF file is
80 stored:
81 v.in.db driver=dbf database=/home/user/tables/ table=pointsfile x=x y=y
82 z=z \
83 key=idcol out=dtmpoints
84 #check result:
85 v.info dtmpoints
86 v.info -c dtmpoints
87
88
89 If an ID column is missing in the DBF file, it has to be added before‐
90 hand, e.g. with OpenOffice.
91
92 4) Import of a points table (x, y, z) from SQLite file to vector points
93 map:
94
95 #create vector map from table in SQLITE database file (here, 'idcol'
96 contains unique row IDs, 'z' is optional):
97 #the 'database' parameter is the the SQLite database file with path:
98 v.in.db driver=sqlite database=/home/user/tables/mysqlite.db ta‐
99 ble=pointsfile x=x y=y z=z \
100 key=idcol out=dtmpoints
101 #check result:
102 v.info dtmpoints
103 v.info -c dtmpoints
104
105
106 If an ID column is missing in the table, it has to be added beforehand
107 with 'sqlite3' or db.execute.
108
109 5) Import of a points table (x, y, z) from DBF file to vector points map
110 for selected points only:
111 The user can import only selected vector points from a table using the
112 where parameter (see above for general DBF handling):
113
114
115 v.in.db driver=dbf database=/home/user/tables/ table=pointsfile x=x
116 y=y z=z \
117 key=idcol out=dtmpoints where="x NOT NULL and z > 100"
118
119
121 db.execute, v.info, v.in.ogr,
122 SQL support in GRASS GIS
123
125 Radim Blazek
126
127 Last changed: $Date: 2007/07/09 15:03:41 $
128
129 Full index
130
131
132
133GRASS 6.2.2 v.in.db(1)