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 name
  • driver=name β€” name of the database driver. Options: dbf, mysql, odbc, ogr, pg, sqlite. Default: sqlite
  • database=name β€” name of the database. Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
  • x=name [required] β€” the name of the column holding the x coordinate
  • y=name [required] β€” the name of the column holding the y coordinate
  • z=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 fr
  • where=sql_query β€” WHERE conditions of an SQL statement, without the where keyword. Example: income < 1000 and population >= 10000
  • output=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 the v.in.db(1grass) page from the GRASS 8.5.0 Reference Manual, Β© 2003-2026 GRASS Development Team, and the footer said GRASS 8.5.0 too, so you know it's current. go make some points maps. periodt. βœ¨πŸ¦‹πŸŒΈ
πŸ“¦ where this page comes from