1v.in.db(1)                  GRASS GIS User's Manual                 v.in.db(1)
2
3
4

NAME

6       v.in.db  - Creates new vector (points) map from database table contain‐
7       ing coordinates.
8

KEYWORDS

10       vector, import, database, points
11

SYNOPSIS

13       v.in.db
14       v.in.db --help
15       v.in.db [-t] table=name  [driver=name]   [database=name]  x=name y=name
16       [z=name]    [key=name]    [where=sql_query]  output=name  [--overwrite]
17       [--help]  [--verbose]  [--quiet]  [--ui]
18
19   Flags:
20       -t
21           Use imported table as attribute table for new map
22
23       --overwrite
24           Allow output files to overwrite existing files
25
26       --help
27           Print usage summary
28
29       --verbose
30           Verbose module output
31
32       --quiet
33           Quiet module output
34
35       --ui
36           Force launching GUI dialog
37
38   Parameters:
39       table=name [required]
40           Input table name
41
42       driver=name
43           Name of database driver
44           Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
45           Default: sqlite
46
47       database=name
48           Name of database
49           Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
50
51       x=name [required]
52           Name of column containing x coordinate
53
54       y=name [required]
55           Name of column containing y coordinate
56
57       z=name
58           Name of column containing z coordinate
59
60       key=name
61           Name of column containing category number
62           Must refer to an integer column
63
64       where=sql_query
65           WHERE conditions of SQL statement without ’where’ keyword
66           Example: income < 1000 and population >= 10000
67
68       output=name [required]
69           Name for output vector map
70

DESCRIPTION

72       v.in.db creates a new vector point map from database table or file con‐
73       taining coordinates.
74

NOTES

76       If GRASS comes with OGR support than v.in.db allows importing data from
77       different input files, eg. CSV or  MS  Excel  (assuming  that  GDAL/OGR
78       library is compiled with this support).
79
80       v.in.db  creates  key column "cat" automatically when key option is not
81       given. Note that this operation is possible to  perform  only  when  -t
82       flag  is not given. Currently, automated creation of key column is sup‐
83       ported only when default DB driver for  output  vector  map  is  SQLite
84       driver  otherwise  key option must be specified by the user. Default DB
85       driver is defined by db.connect.
86

EXAMPLES

88   Creating a map from PostgreSQL table
89       v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
90               table=pat_stazioni x=east y=north z=quota key=id output=pat_stazioni
91
92       If an ID column is not present in the PostgreSQL table,  a  new  column
93       should be added. See PostgreSQL DB driver page for details.
94
95   Creating a map from PostGIS
96       To extract coordinate values from PostGIS, functions have to be used:
97       v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
98               table=station x="x(geom)" y="y(geom)" z="z(geom)" key=id out=meteostations
99
100       If  an  ID  column is not present in the PostgreSQL table, a new column
101       should be added. See PostgreSQL DB driver page for details.
102
103       Alternatively a vector point map can be imported from PostGIS  database
104       using v.in.ogr.
105
106   Creating a map from Open Document spreadsheet (ODS) file
107       A  new  vector  point  map is created from given sheet in ODS file. The
108       database option points to the ODS file. Option table  is  the  name  of
109       selected spreadsheet list, the key option is the identifier column:
110       # preview table structure with OGR tool (table name is "Layer name" here):
111       ogrinfo -al -so meteodata.ods
112       # import sheet from ODS into map
113       v.in.db key=ID table=mysheet x=long y=lat z=height output=meteodata \
114                driver=ogr database=meteodata.ods
115
116   Creating a map from MS Excel file
117       A  new  vector  point map is created from given sheet in MS Excel file.
118       The database option points to the file in MS Excel format. Option table
119       is name of the selected spreadsheet "List1":
120       v.in.db table=List1 x=long y=lat z=height output=meteodata \
121                driver=ogr database=meteodata.xls
122       Note  that  in  this  example  the  key option is omitted. In this case
123       v.in.db tries to add key column automatically. This requires SQLite  to
124       be a default DB driver.
125
126   Creating a map from DBF table
127       A  new  3D  point  vector map is created from DBF table. Column ’idcol’
128       contains unique row IDs. The database option is the directory where the
129       DBF file is stored.
130       v.in.db driver=dbf database=/home/user/tables/ table=pointsfile x=x y=y z=z \
131               key=idcol out=dtmpoints
132       To check result:
133       v.info dtmpoints
134       v.info -c dtmpoints
135
136       If  DB driver for output vector map is different from SQLite driver and
137       an ID column is missing in the DBF file, it has to be added beforehand,
138       e.g.  with  OpenOffice.  Alternatively, import the table with db.in.ogr
139       into GRASS and then with v.in.db from  the  imported  table  (db.in.ogr
140       optionally adds an unique ID column).
141
142   Creating a point map from DBF table for selected records only
143       The  user can import only selected vector points from a table using the
144       where parameter (see above for general DBF handling):
145       v.in.db driver=dbf  database=/home/user/tables/ table=pointsfile x=x y=y z=z \
146               key=idcol out=dtmpoints where="x NOT NULL and z > 100"
147
148   Creating a map from SQLite table
149       A new vector point map is created from table in SQLite  database  file.
150       Column  ’idcol’ contains unique row IDs. The database option is the the
151       SQLite database file.
152       v.in.db driver=sqlite database=/home/user/tables/mysqlite.db table=pointsfile x=x y=y z=z \
153               key=idcol out=dtmpoints
154

SEE ALSO

156        db.execute, db.in.ogr, v.info, v.in.geonames, v.in.ogr, v.to.db
157
158       SQL support in GRASS GIS
159

AUTHORS

161       Radim Blazek
162       Various updates for GRASS 7 by Martin Landa, Czech Technical University
163       in Prague, Czech Republic
164

SOURCE CODE

166       Available at: v.in.db source code (history)
167
168       Main  index  | Vector index | Topics index | Keywords index | Graphical
169       index | Full index
170
171       © 2003-2020 GRASS Development Team, GRASS GIS 7.8.5 Reference Manual
172
173
174
175GRASS 7.8.5                                                         v.in.db(1)
Impressum