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

GRASS logo

NAME

v.clean.ogr - Imports vector data into a GRASS vector map, cleans the data topologically, and exports them again using OGR library.

KEYWORDS

vector, cleaning, OGR, topology, geometry, snapping

SYNOPSIS

v.clean.ogr
v.clean.ogr --help
v.clean.ogr [-luf] input=string layer=string [where=sql_query] [encoding=string] [key=string] [geometry=name] [snap=float] [min_area=float] output=name format=string [--overwrite] [--help] [--verbose] [--quiet] [--ui]

Flags:

-l
List available OGR layers in data source and exit
-u
Open an existing output OGR datasource for update
-f
List supported output formats and exit
--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 OGR datasource to be imported
Example: directory containing shapefiles
layer=string [required]
OGR layer name.
Examples: shapefile name without .shp
where=sql_query
WHERE conditions of SQL statement without 'where' keyword
Example: income < 1000 and population >= 10000
encoding=string
Encoding value for attribute data
Overrides encoding interpretation, useful when importing ESRI Shapefile
key=string
Name of column used for categories
If not given, categories are generated as unique values and stored in 'cat' column
geometry=name
Name of geometry column
If not given, all geometry columns from the input are used
snap=float
Snapping threshold for boundaries (map units)
'-1' for no snap
Default: -1
min_area=float
Minimum size of areas to be retained in output (square meters)
Disabled with values <= 0
Default: 0
output=name [required]
Name of output OGR datasource
Examples: filename for a GeoPackage, directory for shapefiles
format=string [required]
Data format to write
Default: GPKG

Table of contents

DESCRIPTION

v.clean.ogr cleans non-topological polygons in an OGR datasource by importing, cleaning, and exporting these polgons. This module should not be used with polygons that are correctly overlapping, e.g. buffers.

v.clean.ogr imports vector data from files and database connections supported by the OGR library into a temporary location. Only one input layer is imported.

Polygons in the input layer are automatically cleaned during impport. More thorough cleaning can be achieved by using the snap and min_area options.

The cleaned result is exported to the selected output datasource with "_clean" appended to the input layer name. Any overlaps are exported with "_overlaps" appended to the input layer name.

Supported Vector Formats

v.clean.ogr uses the OGR library which supports various vector data formats including GeoPackage, ESRI Shapefile, Mapinfo File, UK .NTF, SDTS, TIGER, IHO S-57 (ENC), DGN, GML, GPX, AVCBin, REC, Memory, OGDI, and PostgreSQL, depending on the local OGR installation. For details see the OGR web site. The OGR (Simple Features Library) is part of the GDAL library, hence GDAL needs to be installed to use v.clean.ogr.

The list of actually supported formats can be printed by -f flag.

NOTES

Topology cleaning

When importing polygons, non-topological polygons are converted to topological areas. If the input polygons contain errors (unexpected overlapping areas, small gaps between polygons, or warnings about being unable to calculate centroids), the import might need to be repeated using a snap value as suggested in the output messages.

The snap threshold defines the maximal distance from one to another vertex in map units (for latitude-longitude locations in degree). If there is no other vertex within snap distance, no snapping will be done. Note that a too large value can severely damage area topology, beyond repair.

Further cleaning can be achieved by removing small areas using the min_area option. Note that units are always squaremeters. Values for min_area should generally be small, a value of 0.5 can already clean up lots of artefacts.

EXAMPLE

Cleaning polygons in a Shapefile in the current directory research_area
v.clean.ogr input=research_area layer=research_area output=research_area \
            snap=1e-4 min_area=1 -u --overwrite
Two new Shapefile layers "research_area_clean" and "research_area_overlaps" may be created in the same directory.

SEE ALSO

v.in.ogr, v.clean, v.out.ogr

AUTHORS

Markus Metz

SOURCE CODE

Available at: v.clean.ogr source code (history)

Latest change: Monday Jun 28 07:54:09 2021 in commit: 1cfc0af029a35a5d6c7dae5ca7204d0eb85dbc55


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

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