Skip to content

v.build.pg

Builds PostGIS topology for vector map linked via v.external.

v.build.pg [-p] map=name [topo_schema=name] topo_column=name [tolerance=float] [--overwrite] [--verbose] [--quiet] [--qq] [--ui]

Example:

v.build.pg map=name topo_column=topo

grass.script.run_command("v.build.pg", map, topo_schema=None, topo_column="topo", tolerance=1, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

gs.run_command("v.build.pg", map="name", topo_column="topo")

grass.tools.Tools.v_build_pg(map, topo_schema=None, topo_column="topo", tolerance=1, flags=None, overwrite=None, verbose=None, quiet=None, superquiet=None)

Example:

tools = Tools()
tools.v_build_pg(map="name", topo_column="topo")

This grass.tools API is experimental in version 8.5 and expected to be stable in version 8.6.

Parameters

map=name [required]
    Name of vector map
topo_schema=name
    Name of schema where to build PostGIS topology
    Default: topo_<map>
topo_column=name [required]
    Name of topology column
    Default: topo
tolerance=float
    Tolerance to snap input geometry to existing primitives
    Default: 1
-p
    Don't execute SQL statements, just print them 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

map : str, required
    Name of vector map
    Used as: input, vector, name
topo_schema : str, optional
    Name of schema where to build PostGIS topology
    Default: topo_<map>
    Used as: name
topo_column : str, required
    Name of topology column
    Used as: name
    Default: topo
tolerance : float, optional
    Tolerance to snap input geometry to existing primitives
    Default: 1
flags : str, optional
    Allowed values: p
    p
        Don't execute SQL statements, just print them 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

map : str, required
    Name of vector map
    Used as: input, vector, name
topo_schema : str, optional
    Name of schema where to build PostGIS topology
    Default: topo_<map>
    Used as: name
topo_column : str, required
    Name of topology column
    Used as: name
    Default: topo
tolerance : float, optional
    Tolerance to snap input geometry to existing primitives
    Default: 1
flags : str, optional
    Allowed values: p
    p
        Don't execute SQL statements, just print them 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.

DESCRIPTION

v.build.pg builds PostGIS topology for feature tables linked via v.external.

NOTES

Note that PostGIS Topology extension is currently under development. v.build.pg requires PostGIS 2.0.0+.

Existing PostGIS topology schema can be overwrite by --overwrite flag.

v.build.pg calls PostGIS functions:

  1. CreateTopology() to create topology schema in the database,
  2. AddTopoGeometryColumn() to add a topogeometry column to an existing feature table, and
  3. toTopoGeom() to create a new topo geometry from the simple feature geometry.

EXAMPLES

Workflow example

Export vector map into PostGIS:

v.out.ogr input=bridges output=PG:dbname=pgis_nc format=PostgreSQL

Create a new vector map as a link to PostGIS table:

v.external input=PG:dbname=pgis_nc layer=bridges

Check metadata:

v.info map=bridges

...
 |----------------------------------------------------------------------------|
 | Map format:      PostGIS (PostgreSQL)                                      |
 | DB table:        public.bridges                                            |
 | DB name:         pgis_nc                                                   |
 | Geometry column: wkb_geometry                                              |
 | Feature type:    point                                                     |
 |----------------------------------------------------------------------------|
...

Build PostGIS topology for the link:

v.build.pg map=bridges

...
Topology topo_bridges (6), SRID 900914, precision 1
10938 nodes, 0 edges, 0 faces, 10938 topogeoms in 1 layers
Layer 1, type Puntal (1), 10938 topogeoms
 Deploy: public.bridges.topo
...

Dry run

For testing issues use -p flag.

v.build.pg map=bridges

Creating new topology schema...

SELECT topology.createtopology('topo_bridges', \
find_srid('public', 'bridges', 'wkb_geometry'), 1)

Adding new topology column...

SELECT topology.AddTopoGeometryColumn('topo_bridges', \
'public', 'bridges', 'topo', 'point')

Building PostGIS topology...

UPDATE bridges SET topo = topology.toTopoGeom(wkb_geometry, \
'topo_bridges', 1, 1)


SELECT topology.TopologySummary('topo_bridges')

SEE ALSO

v.external, v.out.ogr, v.out.postgis, v.build

AUTHOR

Martin Landa, Czech Technical University in Prague, Czech Republic

SOURCE CODE

Available at: v.build.pg source code (history)
Latest change: Thursday Feb 20 13:02:26 2025 in commit 53de819