v.in.db(1grass)
π v.in.db β the GRASS manual, but make it cute β¨
okay bestie, so v.in.db is a GRASS module (that's from the GRASS User's Manual, one of the 1grass pages π) and it's literally the glow-up your boring database table needs, because it turns a table full of coordinates into an actual vector points map. no cap.
π KEYWORDS π
vector, import, database, points
β¨ SYNOPSIS β¨
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]
π Flags π
-tβ use the imported table as the attribute table for the new map π--overwriteβ let output files overwrite existing files (yes, it will really do it, be brave π«Ά)--helpβ print the usage summary--verboseβ verbose module output (it talks more π£οΈ)--quietβ quiet module output (it talks less π€«)--uiβ force launching the GUI dialog β¨
πΈ Parameters πΈ
table=name[required] β the input table namedriver=nameβ name of the database driver. Options:dbf,mysql,odbc,ogr,pg,sqlite. Default:sqlitedatabase=nameβ name of the database. Default:$GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.dbx=name[required] β the name of the column holding the x coordinatey=name[required] β the name of the column holding the y coordinatez=nameβ the name of the column holding the z coordinate (3D girlies rise up π¦)key=nameβ the name of the column holding the category number. Must refer to an integer column, fr frwhere=sql_queryβ WHERE conditions of an SQL statement, without thewherekeyword. Example:income < 1000 and population >= 10000output=name[required] β the name for the output vector map π
π DESCRIPTION π
v.in.db creates a new vector point map from a database table β or a file β that contains coordinates. that's the whole job. it does it. slay. π
π¦ NOTES π¦
If GRASS comes with OGR support, then v.in.db allows importing data from different input files, e.g. CSV or MS Excel (assuming the GDAL/OGR library is compiled with that support). iconic behaviour honestly.
v.in.db creates the key column "cat" automatically when the key option is not given. but heads up bestie, this operation is only possible to perform when the -t flag is not given. also, right now, the automated creation of the key column is supported only when the default DB driver for the output vector map is the SQLite driver β otherwise the key option must be specified by you, the user. the default DB driver is defined by db.connect. iykyk.
πΈ EXAMPLES πΈ
π« Creating a map from PostgreSQL table
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 the PostgreSQL DB driver page for details. π
π« Creating a map from PostGIS
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 the PostgreSQL DB driver page for details.
Alternatively, a vector point map can be imported from a PostGIS database using v.in.ogr. options, we love options β¨
π« Creating a map from Open Document spreadsheet (ODS) file
A new vector point map is created from a given sheet in an ODS file. The database option points to the ODS file. Option table is the name of the 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
π« Creating a map from MS Excel file
A new vector point map is created from a given sheet in an MS Excel file. The database option points to the file in MS Excel format. Option table is the 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 the key column automatically. This requires SQLite to be a default DB driver. π«Ά
π« Creating a map from DBF table
A new 3D point vector map is created from a 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 the result:
v.info dtmpoints
v.info -c dtmpoints
If the DB driver for the output vector map is different from the 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 a unique ID column). π no id column? tragic. fix it first.
π« Creating a point map from DBF table for selected records only
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"
π« Creating a map from SQLite table
A new vector point map is created from a table in a SQLite database file. Column 'idcol' contains unique row IDs. The database option is 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
π SEE ALSO π
db.execute, db.in.ogr, v.info, v.in.geonames, v.in.ogr, v.to.db
SQL support in GRASS
π AUTHORS π
- Radim Blazek
- Various updates for GRASS 7 by Martin Landa, Czech Technical University in Prague, Czech Republic
π SOURCE CODE π
Available at: v.in.db source code (history)
Latest change: Friday Sep 05 13:38:35 2025 in commit: ba8bacf1885bf46c06623094659497cf6adf3fcb
Main index | Vector index | Topics index | Keywords index | Graphical index | Full index
π okay that's the whole page bestie, you ate. this was thev.in.db(1grass)page from the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, and the footer saidGRASS 8.5.0too, so you know it's current. go make some points maps. periodt. β¨π¦πΈ
π¦ where this page comes from
- alpine 3.24: grass-gis-doc 8.5.0-r1 Β· GPL-2.0-or-later
- ubuntu stonking: grass-doc 8.5.0-1ubuntu1 Β· GPL-2.0-or-later
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms