v.in.osm
Imports OpenStreetMap data into GRASS GIS.
v.in.osm [-ol] input=name [output=name] [where=sql_query] [type=string [,string,...]] [table=name] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]
Example:
v.in.osm input=name
grass.tools.Tools.v_in_osm(input, output=None, where=None, type="point,line,boundary,centroid", table=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
tools = Tools()
tools.v_in_osm(input="name")
This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.
grass.script.run_command("v.in.osm", input, output=None, where=None, type="point,line,boundary,centroid", table=None, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)
Example:
gs.run_command("v.in.osm", input="name")
Parameters
input=name [required]
Table file to be imported or DB connection string
output=name
Name for output vector map
where=sql_query
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
type=string [,string,...]
Name for output vector map
Allowed values: point, line, boundary, centroid
Default: point,line,boundary,centroid
table=name
Name of attribute table
-o
Override projection check (use current project's projection)
Assume that the dataset has the same projection as the current project; without this flag the data are reprojected to the current project's CRS
-l
List available OGR layers in data source and exit
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--qq
Very quiet module output
--ui
Force launching GUI dialog
input : str, required
Table file to be imported or DB connection string
Used as: input, file, name
output : str, optional
Name for output vector map
Used as: output, vector, name
where : str, optional
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
Used as: input, sql_query, sql_query
type : str | list[str], optional
Name for output vector map
Allowed values: point, line, boundary, centroid
Default: point,line,boundary,centroid
table : str, optional
Name of attribute table
Used as: input, dbtable, name
flags : str, optional
Allowed values: o, l
o
Override projection check (use current project's projection)
Assume that the dataset has the same projection as the current project; without this flag the data are reprojected to the current project's CRS
l
List available OGR layers in data source and exit
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
Returns:
result : grass.tools.support.ToolResult | None
If the tool produces text as standard output, a ToolResult object will be returned. Otherwise, None will be returned.
Raises:
grass.tools.ToolError: When the tool ended with an error.
input : str, required
Table file to be imported or DB connection string
Used as: input, file, name
output : str, optional
Name for output vector map
Used as: output, vector, name
where : str, optional
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
Used as: input, sql_query, sql_query
type : str | list[str], optional
Name for output vector map
Allowed values: point, line, boundary, centroid
Default: point,line,boundary,centroid
table : str, optional
Name of attribute table
Used as: input, dbtable, name
flags : str, optional
Allowed values: o, l
o
Override projection check (use current project's projection)
Assume that the dataset has the same projection as the current project; without this flag the data are reprojected to the current project's CRS
l
List available OGR layers in data source and exit
overwrite : bool, optional
Allow output files to overwrite existing files
Default: None
verbose : bool, optional
Verbose module output
Default: None
quiet : bool, optional
Quiet module output
Default: None
superquiet : bool, optional
Very quiet module output
Default: None
DESCRIPTION
v.in.osm imports OpenStreetMap data.
The feature types follow the geometry of the selected table (OGR
layer): polygon layers (e.g. multipolygons of an OSM/PBF file or
planet_osm_polygon of an osm2pgsql database) are imported as areas
(boundaries and centroids, with their attributes), point and line layers as
points and lines. Types given in type that do not match the layer
geometry are ignored.
By default the selected features (after the where filter) are reprojected to the coordinate reference system of the current project. With the -o flag the data are imported without reprojection, assuming they are already in the project's CRS.
NOTES
Line layers are split at every vertex and rebuilt into polylines (v.split, v.build.polylines); polygon layers are imported directly with v.in.ogr so that multipolygon rings form areas.
Reprojection is done with GDAL (a temporary GeoPackage in the project CRS) before the import.
EXAMPLES
Import from PostgreSQL DB:
v.in.osm input="PG:host=localhost dbname=gis user=ostepok" table=planet_osm_line \
type=point,line output=roads where="highway is not null"
Import from OSM PBF file:
v.in.osm input=saarland-latest.osm.pbf table=lines type=point,line output=roads \
where="highway is not null"
Import OSM buildings and land use as areas into a projected project:
v.in.osm input=saarland-latest.osm.pbf table=multipolygons output=buildings \
where="building IS NOT NULL"
v.in.osm input=saarland-latest.osm.pbf table=multipolygons output=landuse \
where="landuse IS NOT NULL OR \"natural\" IS NOT NULL"
REQUIREMENTS
GDAL Python bindings (OSM driver). For database input: PostgreSQL, PostGIS, osm2pgsql
SEE ALSO
v.build.polylines, v.import, v.in.ogr
AUTHORS
Stepan Turek
SOURCE CODE
Available at: v.in.osm source code
(history)
Latest change: Wednesday Sep 30 01:58:33 2026 in commit 9e5fa5e