v.out.ogr.1grass man page

v.out.ogr — Exports a vector map layer to any of the supported OGR vector formats.
By default a vector map layer is exported to Esri Shapefile format.


vector, export, OGR


v.out.ogr --help
v.out.ogr [-uasce2mn] input=name [layer=string] [type=string[,string,...]] output=string format=string [output_layer=string] [output_type=string[,string,...]] [dsco=string[,string,...]] [lco=string[,string,...]] [--overwrite] [--help] [--verbose] [--quiet] [--ui]


Open an existing OGR datasource for update
Append to existing layer
A new OGR layer is created if it does not exist
Skip export of GRASS category ID (’cat’) attribute
Also export features without category (not labeled). Otherwise only features with category are exported.
Use ESRI-style .prj file format (applies to Shapefile output only)
Force 2D output even if input is 3D (applies to Shapefile output only)
Useful if input is 3D but all z coordinates are identical
Export vector data as multi-features
Create a new empty layer in defined OGR datasource and exit. Nothing is read from input.
Allow output files to overwrite existing files
Print usage summary
Verbose module output
Quiet module output
Force launching GUI dialog


input=name [required]
Name of input vector map to export
Or data source for direct OGR access
Layer number or name
Vector features can have category values in different layers. This number determines which layer to use. When used with direct OGR access this is the layer name.
Default: 1
Feature type(s)
Combination of types is not supported by all output formats. Default is to use first type found in input vector map.
Options: point, line, boundary, centroid, area, face, kernel, auto
Default: auto
output=string [required]
Name of output OGR datasource
For example: ESRI Shapefile: filename or directory for storage
PostGIS database: connection string
format=string [required]
Data format to write
Options: AmigoCloud, BNA, CSV, CartoDB, Cloudant, CouchDB, DGN, DXF, ESRI_Shapefile, ElasticSearch, GFT, GML, GPKG, GPSBabel, GPSTrackMaker, GPX, GeoJSON, GeoRSS, Geoconcept, Interlis_1, Interlis_2, JML, KML, LIBKML, MSSQLSpatial, MapInfo_File, Memory, MySQL, ODBC, ODS, OGR_GMT, PCIDSK, PDF, PGDUMP, PostgreSQL, S57, SQLite, Selafin, TIGER, VDV, WAsP, XLSX, netCDF
Default: ESRI_Shapefile
Name for output OGR layer. If not specified, input name is used
For example: ESRI Shapefile: shapefile name
PostGIS database: table name
Optionally change default output type
Options: line, boundary
line: export area boundaries as linestrings
boundary: export lines as polygons
OGR dataset creation option (format specific, NAME=VALUE)
OGR layer creation option (format specific, NAME=VALUE)


v.out.ogr converts GRASS vector map layer to any of the supported OGR vector formats (like a Esri Shapefile, SpatiaLite or GML).

OGR (Simple Features Library) is part of the GDAL library, so you need to install this library to use v.out.ogr.

The OGR library supports many various formats including:

ESRI Shapefile
Mapinfo File
... and many others

For further available other supported formats go here.


By default, islands will appear as holes inside surrounding areas. To export polygons with holes into, e.g., a Esri Shapefile, and make the holes appear as filled areas, the flag -c has to be used.

v.out.ogr exports 3D vector data as 2.5D simple features if possible (not supported by all formats). For exporting 3D vector data as 2D simple features, use -2 flag.

By default, v.out.ogr converts GRASS vector data to single simple features. If GRASS feature has more categories defined in the given layer, then this feature is exported multiple times. GRASS features without category are skipped by default. To export features also without category, the -c flag must be given.

When -m flag is given, v.out.ogr export GRASS vector data as multi-features. Multi-feature is formed by GRASS features with the same category. When -c flag is given, the module also export GRASS features without category as one multi-feature. Note that multi-features are not supported by all formats.

ESRI Shapefile export: note that due to the DBF table specifications column names may not be longer than 10 characters.


Export to ESRI Shapefile

Export lines from GRASS vector map to Shapefile format:

v.out.ogr input=lines type=line output=lines.shp

Export areas from GRASS vector map to Shapefile format, converting islands (holes) to filled polygons:

v.out.ogr -c input=areas_islands type=area output=areas_islands.shp

Export 3D lines from GRASS vector map to Shapefile format:

v.out.ogr input=lines_3d type=line output=lines_3d.shp lco="SHPT=ARCZ"

Export 3D points (e.g., Lidar points) from GRASS vector map to Shapefile format

v.out.ogr points_3d type=point output=points_3d.shp lco="SHPT=POINTZ"

Export 3D faces from GRASS vector map to Shapefile format:

v.out.ogr input=objects_3d type=face output=faces_3d.shp lco="SHPT=POLYGONZ"

Export 3D faces from GRASS vector map to Shapefile format, automatic 3D setting:

v.out.ogr input=objects_3d type=face output=faces_3d.shp"

Export to GML

Export lines from GRASS vector map to GML format (generates ’/tmp/testogr.gml’ file with layer ’testogr’):

v.out.ogr input=multi type=line output=/tmp/testogr.gml output_layer=testogr format=GML

Export to PostgreSQL/PostGIS

Export areas from GRASS vector map to PostGIS database:

v.out.ogr input=polygons type=area output="PG:host=localhost dbname=postgis user=postgres" output_layer=polymap format=PostgreSQL

Note: For exporting GRASS vector data to PostGIS database can be also used v.out.postgis module. This module is not based on OGR library and supports beside simple features also topological format (PostGIS Topology).

Export to KML (Google Earth)

Export faces (3D vectors) from GRASS vector map to KML format for Google Earth:

v.out.ogr input=buildings_3d output=buildings_3d.kml output_layer=buildings_3d format=KML type=face

Generate and export GRASS vector "asteroid" map (faces, 3D vectors) to KML format for Google Earth:

# near Raleigh (NC, USA)
g.region n=35.73952587 s=35.73279182 w=-78.68263928 e=-78.67499517
# two layers of random points
v.random -z output=random3d_a n=10 zmin=0 zmax=200
v.random -z output=random3d_b n=15 zmin=400 zmax=600
# merge into one 3D points map
v.patch input=random3d_a,random3d_b output=random3d
# generate 3D convex hull
v.hull input=random3d output="random3d_hull"
# export to KML 3D
v.out.ogr input=random3d_hull output=random3d_hull.kml format=KML type=face dsco="AltitudeMode=absolute"
# now open KML file ’random3d_hull.kml’ in Google Earth or NASA WorldWind or ...


OGR vector library
OGR vector library C API documentation

See Also

v.out.postgis, db.out.ogr, v.external, v.external.out, v.in.ogr, v.pack


Radim Blazek, ITC-Irst, Trento, Italy
Some contributions: Markus Neteler
Multi-feature support by Martin Landa, Czech Technical University in Prague, 2013

Last changed: $Date: 2015-11-24 09:08:30 +0100 (Tue, 24 Nov 2015) $

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

© 2003-2016 GRASS Development Team, GRASS GIS 7.0.4 Reference Manual


GRASS 7.0.4 Grass User's Manual