Scroll to navigation

v.out.ogr(1grass) Grass User's Manual v.out.ogr(1grass)

NAME

v.out.ogr - Converts GRASS vector map to one of the supported OGR vector formats.

KEYWORDS

vector, export

SYNOPSIS

v.out.ogr
 
v.out.ogr help
 
v.out.ogr [-uscezp] input=name [type=string[, string,...]] dsn=string [olayer= string] [layer=integer] [format=string] [dsco=string[,string,...]] [ lco=string[,string,...]] [--verbose] [--quiet]

Flags:

-u
 
Open an existing datasource for update
-s
 
Skip export of GRASS category ID ('cat') attribute
-c
 
Export features with category (labeled) only. Otherwise all features are exported
-e
 
Use ESRI-style .prj file format (applies to Shapefile output only)
-z
 
Create 3D output if input is 3D (applies to Shapefile output only)
-p
 
Export lines as polygons
--verbose
 
Verbose module output
--quiet
 
Quiet module output

Parameters:

input=name
 
Name of input vector map
type=string[,string,...]
 
Feature type(s). Combinations not supported by all output formats. Default: first type found in input.
 
Options: point,line,boundary,centroid,area,face,kernel,auto
 
Default: line,boundary
dsn=string
 
OGR output datasource name
 
For example: ESRI Shapefile: filename or directory for storage
olayer=string
 
OGR layer name. If not specified, input name is used.
 
For example: ESRI Shapefile: shapefile name
layer=integer
 
Layer number
 
A single vector map can be connected to multiple database tables. This number determines which table to use.
 
Default: 1
format=string
 
OGR format
 
Options: ESRI_Shapefile,MapInfo_File,TIGER,S57,DGN,Memory,BNA,CSV,GML,GPX,LIBKML,KML,GeoJSON,Interlis_1,Interlis_2,GMT,SQLite,ODBC,MSSQLSpatial,PostgreSQL,MySQL,PCIDSK,DXF,Geoconcept,GeoRSS,GPSTrackMaker,PGDump,GPSBabel,GFT,CouchDB,ODS,XLSX,ElasticSearch,PDF
 
Default: ESRI_Shapefile
dsco=string[,string,...]
 
OGR dataset creation option (format specific, NAME=VALUE)
 
Default:
lco=string[,string,...]
 
OGR layer creation option (format specific, NAME=VALUE)
 
Default:

DESCRIPTION

v.out.ogr converts GRASS vector data to OGR format. OGR (Simple Features Library) is part of the GDAL library, so you need to install gdal to use v.out.ogr.

Supported OGR Vector Formats

ESRI Shapefile
 
CSV
 
GML
 
KML
 
Mapinfo File
 
PostgreSQL/PostGIS
 
TIGER
For further available drivers go here.

NOTES

To export areas with holes into, e.g., a Shapefile, while keeping the holes as holes, the flag -c has to be used.
The "-z" flag can be used to automatically export a 3D map to a 3D Shapefile, instead of setting the correct lco= option manually.

EXAMPLES

Export to Shapefile

Export lines from GRASS vector map to Shapefile format:
 
v.out.ogr input=lines type=line dsn=lines.shp
 
Export areas from GRASS vector map to Shapefile format, preserving islands:
 
v.out.ogr -c input=areas_islands type=area dsn=areas_islands.shp
 
Export 3D lines from GRASS vector map to Shapefile format:
 
v.out.ogr input=lines_3d type=line dsn=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 dsn=points_3d.shp lco="SHPT=POINTZ"
 
Export 3D faces from GRASS vector map to Shapefile format:
 
v.out.ogr input=objects_3d type=face dsn=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 dsn=faces_3d.shp -z
 

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 dsn=/tmp/testogr.gml olayer=testogr format=GML
 

Export to PostgreSQL/PostGIS

Export areas from GRASS vector map directly to PostGIS:
 
v.out.ogr input=polygons type=area \
 

dsn="PG:host=localhost dbname=postgis user=postgres" \
 

olayer=polymap format=PostgreSQL
 

Export to KML (Google Earth)

Example 1 (Latitude-Longitude location):
 
Export faces (3D vectors) from GRASS vector map to KML format for Google Earth:
 
v.out.ogr input=buildings_3d dsn=buildings_3d.kml olayer=buildings_3d \
 

format=KML type=face
 
Example 2 (Latitude-Longitude location):
 
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 dsn=random3d_hull.kml format=KML \
 

type=face dsco="AltitudeMode=absolute"
 
 
# now open KML file 'random3d_hull.kml' in Google Earth or NASA WorldWind or ...
 

REFERENCES

OGR vector library
 
OGR vector library C API documentation

SEE ALSO

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

AUTHORS

Radim Blazek, ITC-Irst, Trento, Italy
 
Some contributions: Markus Neteler, Martin Landa
Last changed: $Date: 2014-01-02 22:54:21 +0100 (Thu, 02 Jan 2014) $
Full index
© 2003-2014 GRASS Development Team
GRASS 6.4.4