GRASS logo

Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.

NAME

v.external - Creates a new pseudo-vector map as a link to an OGR-supported layer or a PostGIS feature table.

KEYWORDS

vector, import, external, OGR, PostGIS, level1

SYNOPSIS

v.external
v.external --help
v.external [-ojfltb] input=string [layer=name] [where=sql_query] [output=name] [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-o
Override projection check (use current location's projection)
Assume that the dataset has the same projection as the current location
-j
Perform projection check only and exit
-f
List supported formats and exit
-l
List available layers in data source and exit
-t
List available layers including feature type in data source and exit
Format: layer name,type,projection check,geometry
-b
Do not build topology
Advantageous when handling a large number of points
--overwrite
Allow output files to overwrite existing files
--help
Print usage summary
--verbose
Verbose module output
--quiet
Quiet module output
--ui
Force launching GUI dialog

Parameters:

input=string [required]
Name of input OGR or PostGIS data source
Examples:
        ESRI Shapefile: directory containing a shapefile
        MapInfo File: directory containing a mapinfo file
        PostGIS database: connection string, eg. 'PG:dbname=db user=grass'
layer=name
Name of OGR layer or PostGIS feature table to be linked
Examples:
        ESRI Shapefile: shapefile name
        MapInfo File: mapinfo file name
        PostGIS database: table name
where=sql_query
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
output=name
Name for output GRASS vector map (default: input layer)

Table of contents

DESCRIPTION

v.external creates new vector map as a link to external OGR layer or PostGIS feature table. OGR (Simple Features Library) is part of the GDAL library, so you need to install GDAL to use v.external for external OGR layers. Note that a PostGIS feature table can be linked also using built-in GRASS-PostGIS data driver (requires GRASS to be built with PostgreSQL support).

NOTES

The simple feature data model used by OGR (or PostGIS) is very different from the topological format used by GRASS. Instead of true topology, so called 'pseudo topology' is created for data linked by v.external. User should learn the difference between those two formats, because some modules working correctly with GRASS native data, can produce wrong results with input vector maps created by v.external.

Limitations:

Due to these data model differences v.external does not work with all data formats. In general, for all formats that do not have a key column (e.g. SHAPE file), attributes are not accessible, and attributes would get lost when modifying the geometries. Therefore it is generally not safe to link vector data with v.external. In many cases it does not make sense to use v.external linked data with simple features, instead vector data should be imported with v.import or v.in.ogr to get true topology support. Importantly, point cloud data which do not have topology, can be linked with v.external as long as there are no attributes attached to these point cloud data, or if the format of the point cloud data has a key column that allows linking vector geometries to attributes.

See v.db.connect for an example of maintaining attributes in external DBMS in also writable mode.

Supported OGR vector formats

To list supported OGR formats, type
v.external -f
For details see GDAL web site.

EXAMPLES

ESRI Shapefile

Assuming that 'test_shape.shp' is located in directory '/home/user/shape_data'.
v.external input=/home/user/shape_data layer=test_shape output=grass_map 

PostGIS layers

By default, PostGIS links are created by built-in PostGIS support, ie. using GRASS-PostGIS data driver. If the environment variable GRASS_VECTOR_OGR exists, or GRASS is compiled without PostgreSQL support then GRASS will use OGR-PostgreSQL driver for creating a link.

List of layers for given data source can be printed by -l flag.

v.external input="PG:host=localhost user=postgres dbname=postgis" -l

...
polymap
...
v.external input="PG:host=localhost user=postgres dbname=postgis" layer=polymap
Note: Authentication details (user password) can be preferably defined by db.login.

MapInfo files

Assuming that 'mapinfo_test' MapInfo file is located in the current directory (".").
v.external input=./ layer=mapinfo_test output=grass_map

SDTS files

Note: you have to select the CATD file
v.external input=CITXCATD.DDF output=cities

TIGER files

v.external input=input/2000/56015/ layer=CompleteChain,PIP output=t56015_all

Linking subset of features

By where option only subset of features can be linked. In the example below only one feature (in this case a vector tile) will be linked as a new GRASS vector map.
v.external in="PG:dbname=tiles" layer=wrs2_descending where="pr=191026" 
...
Number of areas: 1
...

REFERENCES

OGR vector library C API documentation

SEE ALSO

v.external.out, v.clean, v.db.connect, v.import, v.in.db, v.in.ogr, v.out.ogr

GDAL Library
PostGIS

See also GRASS user wiki page for more examples.

AUTHORS

Radim Blazek, ITC-Irst, Trento, Italy
PostGIS support by Martin Landa, GeoForAll (OSGeoREL) Lab, Czech Technical University in Prague, Czech Republic

SOURCE CODE

Available at: v.external source code (history)

Latest change: Thursday Feb 03 11:10:06 2022 in commit: 547ff44e6aecfb4c9cbf6a4717fc14e521bec0be


Note: This document is for an older version of GRASS GIS that will be discontinued soon. You should upgrade, and read the current manual page.

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

© 2003-2023 GRASS Development Team, GRASS GIS 8.2.2dev Reference Manual