v.in.db(1)

πŸ’– v.in.db πŸ’–

okay bestie, welcome to the v.in.db page from the GRASS GIS User's Manual β€” yes it's a version 8.4.2 era manual page, yes it's a whole vibe, and yes, I'm about to make a database-to-vector-point-map tool sound like the most iconic thing you've ever heard. because honestly? it kind of is. πŸ¦‹


✨ NAME ✨

v.in.db β€” creates a brand new vector (points) map from a database table that's holding coordinates. like, the table has the numbers, and this module turns them into a whole map. slay.


🏷️ 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. periodt.
  • --overwrite β€” allow output files to overwrite existing files (aka permission to be messy πŸ’…)
  • --help β€” print usage summary
  • --verbose β€” verbose module output
  • --quiet β€” quiet module output
  • --ui β€” force launching GUI dialog

πŸŽ€ Parameters

  • table=name [required] β€” input table name
  • driver=name β€” name of database driver
    • Options: dbf, mesql, mysql, odbc, ogr, pg, sqlite
    • Default: sqlite
  • database=name β€” name of database
    • Default: $GISDBASE/$LOCATION_NAME/$MAPSET/sqlite/sqlite.db
  • x=name [required] β€” name of the column that's holding the x coordinate
  • y=name [required] β€” name of the column that's holding the y coordinate
  • z=name β€” name of the column that's holding the z coordinate
  • key=name β€” name of the column containing the category number. must refer to an integer column, no cap.
  • where=sql_query β€” WHERE conditions of an SQL statement, without the ’where’ keyword
    • Example: income < 1000 and population >= 10000
  • output=name [required] β€” name for output vector map

🌸 DESCRIPTION 🌸

v.in.db creates a new vector point map from a database table or file that contains coordinates. that's it, that's the whole job, and it eats every single time. πŸ”₯


πŸ“ 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 was compiled with that support). so like, your spreadsheet can just. become a map. iconic behavior.

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, currently 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 the user. the default DB driver is defined by db.connect. so basically: check your driver before you assume the magic is gonna happen, okay? πŸ™ˆ


πŸ’… 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. two ways to get the same snack, love that for us. ✨

πŸ“„ 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. the table option is the name of the selected spreadsheet list, and 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. the table option 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 the default DB driver. no pressure, just saying. 🫢

πŸ—ƒοΈ Creating a map from DBF table

A new 3D point vector map is created from a DBF table. the 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 use v.in.db from the imported table (db.in.ogr optionally adds a unique ID column). flexible? we love to see it.

πŸ” 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. the 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 GIS


πŸ‘‘ 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)

Accessed: Saturday Jan 17 05:41:21 2026

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


and that's the whole page bestie!! πŸŽ€ this little manual page is Β© 2003-2025 GRASS Development Team, and it's serving the GRASS GIS 8.4.2 Reference Manual energy β€” accessed on that Saturday Jan 17 05:41:21 2026 timestamp up there. now go make some points maps, you absolute main character. πŸ’–βœ¨πŸ¦‹
πŸ“¦ where this page comes from