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