If the layer parameter is not given, all available OGR layers are imported as separate GRASS layers into one GRASS vector map. If several OGR layer names are given, all these layers are imported as separate GRASS layers into one GRASS vector map.
The optional spatial parameter defines spatial query extents. This parameter allows the user to restrict the region to a spatial subset while importing the data. All vector features completely or partially falling into this rectangle subregion are imported. The -r current region flag is identical, but uses the current region settings as the spatial bounds (see g.region).
The list of actually supported formats can be printed by -f flag.
The min_area threshold value is being specified as area size in map units with the exception of latitude-longitude locations in which it is being specified solely in square meters.
The snap threshold value is used to snap boundary vertices to each other if the distance in map units between two vertices is not larger than the threshold. Snapping is by default disabled with -1. See also the v.clean manual.
If the user wishes to ignore the difference between the apparent coordinate system of the source data and the current location, they may pass the -o flag to override the projection check.
If the user wishes to import the data with the full projection definition, it is possible to have v.in.ogr automatically create a new location based on the projection and extents of the file being read. This is accomplished by passing the name to be used for the new location via the location parameter. Upon completion of the command, a new location will have been created (with only a PERMANENT mapset), and the vector map will have been imported with the indicated output name into the PERMANENT mapset.
An interesting wrapper command around v.in.ogr is v.import which reprojects (if needed) the vector dataset during import to the projection of the current location.
[A-Za-z][A-Za-z0-9_]*
v.in.ogr converts '.', '-' and '#' to '_' (underscore) during import. The -w flag changes capital column names to lowercase characters as a convenience for SQL usage (lowercase column names avoid the need to quote them if the attribute table is stored in a SQL DBMS such as PostgreSQL). The cnames parameter is used to define new column names during import.
The DBF database specification limits column names to 10 characters. If the default DB is set to DBF and the input data contains longer column/field names, they will be truncated. If this results in multiple columns with the same name then v.in.ogr will produce an error. In this case you will either have to modify the input data or use v.in.ogr's cnames parameter to rename columns to something unique. (hint: copy and modify the list given with the error message). Alternatively, change the local DB with db.connect.
When importing Esri Shapefiles the OGR library tries to read the LDID/codepage setting from the .dbf file and use it to translate string fields to UTF-8. LDID "87 / 0x57" is treated as ISO8859_1 which may not be appropriate for many languages. Unfortunately it is not clear what other values may be appropriate (see example below). To change encoding the user can set up SHAPE_ENCODING environmental variable or simply to define encoding value using encoding parameter. Note that recoding support is new for GDAL/OGR 1.9.0.
Value for encoding also affects text recoding when importing DXF files. For other formats has encoding value no effect.
Option key specifies column name used for feature categories. This column must be integer. If not specified, categories numbers are generated starting with 1 and stored in the column named "cat".
Starting with GDAL 1.11 the library supports multiple geometry columns in OGR. By default v.in.ogr reads all geometry columns from given layer. The user can choose desired geometry column by geometry option, see example below.
v.in.ogr input=/home/user/shape_data/test_shape.shp output=grass_map
v.in.ogr input=/home/user/shape_data layer=test_shape output=grass_map
v.in.ogr input=/home/user/shape_data/test_shape.shp output=grass_map encoding=cp1250
v.in.ogr input=./ layer=mapinfo_test output=grass_map
v.in.ogr input=gemeinden layer=LAB,ARC type=centroid,boundary output=mymap
First we have to convert the E00 file to an Arc Coverage with 'avcimport' (AVCE00 tools, use e00conv first in case that avcimport fails):
avcimport e00file coverage v.in.ogr input=coverage layer=LAB,ARC type=centroid,boundary output=mymap
v.in.ogr input=CITXCATD.DDF output=cities
v.in.ogr input=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all \ type=boundary,centroid snap=-1
v.in.ogr input="PG:host=localhost dbname=postgis user=postgres" layer=polymap \ output=polygons type=boundary,centroid
For schema support, first set a default schema with db.connect. If schema support is used the schema name must be specified whenever a db.* module is called. User and password for connection to the database can be specified by db.login.
Example (with schema):
db.connect driver=pg database=test schema=user1 db.login user=user1 password=pwd1 # -> input="PG:dbname=test user=user1 password=pwd1" layer="user1.river" v.in.ogr input=PG: layer=river output=river db.select table=user1.river
The user can ignore schemas, if desired:
db.connect driver=pg database=test db.login user=user1 password=pwd1 # -> input="PG:dbname=test user=user1 password=pwd1" v.in.ogr input=PG: layer=river output=river db.select table=river
v.in.ogr input=OCI:username/password@database_instance output=grasslayer layer=roads_oci
v.external -t input=20141130_ST_UKSH.xml.gz ... Okresy,point,1,DefinicniBod Okresy,multipolygon,1,OriginalniHranice Okresy,multipolygon,1,GeneralizovaneHranice ...
v.in.ogr input=20141130_ST_UKSH.xml.gz layer=Okresy geometry=OriginalniHranice
If a message like "Try to import again, snapping with at least 1e-008: 'snap=1e-008'" appears, then the map to be imported contains topological errors. The message suggests a value for the snap parameter to be tried. For more details, see above in Topology Cleaning.
GRASS GIS Wiki page: Import of Global datasets
Last changed: $Date$