GSP
Quick Navigator

Search Site

Unix VPS
A - Starter
B - Basic
C - Preferred
D - Commercial
MPS - Dedicated
Previous VPSs
* Sign Up! *

Support
Contact Us
Online Help
Handbooks
Domain Status
Man Pages

FAQ
Virtual Servers
Pricing
Billing
Technical

Network
Facilities
Connectivity
Topology Map

Miscellaneous
Server Agreement
Year 2038
Credits
 

USA Flag

 

 

Man Pages
v.in.db(1) GRASS GIS User's Manual v.in.db(1)

v.in.db - Creates new vector (points) map from database table containing coordinates.

vector, import, database, points

v.in.db
v.in.db --help
v.in.db [-t] table=name [driver=name] [database=name] x=name y=name [z=name] [key=name] [where=sql_query] output=name [--overwrite] [--help] [--verbose] [--quiet] [--ui]

-t

Use imported table as attribute table for new map
--overwrite

Allow output files to overwrite existing files
--help

Print usage summary
--verbose

Verbose module output
--quiet

Quiet module output
--ui

Force launching GUI dialog

table=name [required]

Input table name
driver=name

Name of database driver
Options: dbf, ogr, pg, sqlite
Default: sqlite
database=name

Name of database
Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
x=name [required]

Name of column containing x coordinate
y=name [required]

Name of column containing y coordinate
z=name

Name of column containing z coordinate
key=name

Name of column containing category number
Must refer to an integer column
where=sql_query

WHERE conditions of SQL statement without ’where’ keyword
Example: income < 1000 and population >= 10000
output=name [required]

Name for output vector map

v.in.db creates a new vector point map from database table or file containing coordinates.

If GRASS comes with OGR support than v.in.db allows importing data from different input files, eg. CSV or MS Excel (assuming that GDAL/OGR library is compiled with this support).

v.in.db creates key column "cat" automatically when key option is not given. Note that this operation is possible to perform only when -t flag is not given. Currently, automated creation of key column is supported only when default DB driver for output vector map is SQLite driver otherwise key option must be specified by the user. Default DB driver is defined by db.connect.


v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
        table=pat_stazioni x=east y=north z=quota key=id output=pat_stazioni

If an ID column is not present in the PostgreSQL table, a new column should be added. See PostgreSQL DB driver page for details.

To extract coordinate values from PostGIS, functions have to be used:

v.in.db driver=pg database="host=myserver.itc.it,dbname=mydb" \
        table=station x="x(geom)" y="y(geom)" z="z(geom)" key=id out=meteostations

If an ID column is not present in the PostgreSQL table, a new column should be added. See PostgreSQL DB driver page for details.

Alternatively a vector point map can be imported from PostGIS database using v.in.ogr.

A new vector point map is created from given sheet in ODS file. The database option points to the ODS file. Option table is the name of selected spreadsheet list, the key option is the identifier column:

# preview table structure with OGR tool (table name is "Layer name" here):
ogrinfo -al -so meteodata.ods
# import sheet from ODS into map
v.in.db key=ID table=mysheet x=long y=lat z=height output=meteodata \
         driver=ogr database=meteodata.ods

A new vector point map is created from given sheet in MS Excel file. The database option points to the file in MS Excel format. Option table is name of the selected spreadsheet "List1":

v.in.db table=List1 x=long y=lat z=height output=meteodata \
         driver=ogr database=meteodata.xls

Note that in this example the key option is omitted. In this case v.in.db tries to add key column automatically. This requires SQLite to be a default DB driver.

A new 3D point vector map is created from DBF table. Column ’idcol’ contains unique row IDs. The database option is the directory where the DBF file is stored.

v.in.db driver=dbf database=/home/user/tables/ table=pointsfile x=x y=y z=z \
        key=idcol out=dtmpoints

To check result:

v.info dtmpoints
v.info -c dtmpoints

If DB driver for output vector map is different from SQLite driver and an ID column is missing in the DBF file, it has to be added beforehand, e.g. with OpenOffice. Alternatively, import the table with db.in.ogr into GRASS and then with v.in.db from the imported table (db.in.ogr optionally adds an unique ID column).

The user can import only selected vector points from a table using the where parameter (see above for general DBF handling):

v.in.db driver=dbf  database=/home/user/tables/ table=pointsfile x=x y=y z=z \
        key=idcol out=dtmpoints where="x NOT NULL and z > 100"

A new vector point map is created from table in SQLite database file. Column ’idcol’ contains unique row IDs. The database option is the the SQLite database file.

v.in.db driver=sqlite database=/home/user/tables/mysqlite.db table=pointsfile x=x y=y z=z \
        key=idcol out=dtmpoints

db.execute, db.in.ogr, v.info, v.in.geonames, v.in.ogr, v.to.db

SQL support in GRASS GIS

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

Available at: v.in.db source code (history)

Main index | Vector index | Topics index | Keywords index | Graphical index | Full index

© 2003-2021 GRASS Development Team, GRASS GIS 7.8.6 Reference Manual

GRASS 7.8.6

Search for    or go to Top of page |  Section 1 |  Main Index

Powered by GSP Visit the GSP FreeBSD Man Page Interface.
Output converted with ManDoc.