Title: | Cleaning Geometries from Spatial Objects |
---|---|
Description: | Provides a set of utility tools to inspect spatial objects, facilitate handling and reporting of topology errors and geometry validity issue with sp objects. Finally, it provides a geometry cleaner that will fix all geometry problems, and eliminate (at least reduce) the likelihood of having issues when doing spatial data processing. |
Authors: | Emmanuel Blondel [aut, cre] |
Maintainer: | Emmanuel Blondel <[email protected]> |
License: | GPL (>= 2) |
Version: | 0.3-1 |
Built: | 2024-10-25 02:59:56 UTC |
Source: | https://github.com/eblondel/cleangeo |
cleangeo provides a set of utility tools to inspect spatial objects, facilitate handling and reporting of topology errors and geometry validity issues. Finally, it provides a geometry cleaner that will fix all geometry problems, and eliminate (at least reduce) the likelihood of having issues when doing spatial data processing.
Emmanuel Blondel [email protected]
Function to clean a spatial data collection
clgeo_Clean(sp, errors.only = NULL, strategy = "SF", verbose = FALSE)
clgeo_Clean(sp, errors.only = NULL, strategy = "SF", verbose = FALSE)
sp |
object extending the |
errors.only |
an object of class |
strategy |
advanced strategy to clean geometries. Default is "SF", alternate values are "POLYGONATION, "BUFFER" (old methods). |
verbose |
Indicates wether the clean logs have to be printed. Default value is FALSE. |
an object extending the Spatial-class
as defined in sp, with cleaned geometries.
About cleaning strategy:
The polygonation method is a tentative alternate method to triangulation to clean
geometries and to the classical often used 'buffer' approach. In the polygonation
method, triangulation is skipped and a re-polygonation intuitive algorithm is
applied to rebuild the source invalid geometry into one or more valid polygonal
geometries.
With the progress done on validating geometries, especially with sf, the default
method in cleangeo has now been switched to the use of sf::st_make_valid
Emmanuel Blondel [email protected]
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") sp.clean <- clgeo_Clean(sp) report.clean <- clgeo_CollectionReport(sp.clean) clgeo_SummaryReport(report.clean)
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") sp.clean <- clgeo_Clean(sp) report.clean <- clgeo_CollectionReport(sp.clean) clgeo_SummaryReport(report.clean)
Function to clean a Polygon-class
object by polygonation.
clgeo_CleanByPolygonation.Polygon(p, verbose = FALSE)
clgeo_CleanByPolygonation.Polygon(p, verbose = FALSE)
p |
object of class |
verbose |
Indicates wether the clean logs have to be printed. Default value is FALSE. |
a list of objects of class Polygon-class
as defined in sp,
with cleaned geometries.
The polygonation method is a tentative alternate method to triangulation to clean geometries. In this method, triangulation is skipped and a re-polygonation algorithm is applied.
Emmanuel Blondel [email protected]
Function to clean a Polygons
object by polygonation
clgeo_CleanByPolygonation.Polygons(p, verbose = FALSE)
clgeo_CleanByPolygonation.Polygons(p, verbose = FALSE)
p |
object of class |
verbose |
Indicates wether the clean logs have to be printed. Default value is FALSE. |
an object of class Polygons-class
as defined in sp,
with cleaned geometries.
The polygonation method is a tentative alternate method to triangulation to clean geometries. In this method, triangulation is skipped and a re-polygonation algorithm is applied.
Emmanuel Blondel [email protected]
Function to clean a SpatialPolygons
object by polygonation
clgeo_CleanByPolygonation.SpatialPolygons(sp, verbose = FALSE)
clgeo_CleanByPolygonation.SpatialPolygons(sp, verbose = FALSE)
sp |
object extending the |
verbose |
Indicates wether the clean logs have to be printed. Default value is FALSE. |
an object extending the Spatial-class
as defined in sp,
with cleaned geometries.
The polygonation method is a tentative alternate method to triangulation to clean geometries. In this method, triangulation is skipped and a re-polygonation algorithm is applied.
Emmanuel Blondel [email protected]
Function to get a spatial data collection validation report. The function outputs
a data.frame
binding all geometry validity reports, each one produced by
clgeo_GeometryReport
clgeo_CollectionReport(sp)
clgeo_CollectionReport(sp)
sp |
object extending the |
an object of class data.frame
with the following columns:
type eventual rgeos issue
valid geometry validity status (according to OGC specifications)
issue_type type of geometry issue
error_msg catched message when error raised about geometry
warning_msg catched message when warning raised about geometry
Emmanuel Blondel [email protected]
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp)
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp)
Function to get a geometry validation report: The report informs on the following:
type eventual rgeos issue
valid geometry validity status (according to OGC specifications)
issue_type type of geometry issue
msg catched message when error raised about geometry
clgeo_GeometryReport(spgeom)
clgeo_GeometryReport(spgeom)
spgeom |
object extending the |
an object of class list
giving the following:
type eventual rgeos issue
valid geometry validity status (according to OGC specifications)
issue_type type of geometry issue
msg catched message when warning raised about geometry
Emmanuel Blondel [email protected]
Wrapper method to try performing rgeos::gIsValid call and catch eventual warnings or errors (in particular GEOS exceptions).
clgeo_IsValid(sp, verbose = FALSE)
clgeo_IsValid(sp, verbose = FALSE)
sp |
object extending the |
verbose |
object of class "logical". Default value is FALSE. |
an object of class "logical". TRUE if valid, FALSE otherwise
Emmanuel Blondel [email protected]
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") clgeo_IsValid(sp)
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") clgeo_IsValid(sp)
Function to get summary of a spatial data collection report returned by
clgeo_CollectionReport
clgeo_SummaryReport(report)
clgeo_SummaryReport(report)
report |
a report object as returned by |
an object of class table
giving the report summary. The summary
gives the counting by value for each of the report columns:
type eventual geometry issue
valid geometry validity status (according to OGC specifications)
issue_type type of geometry issue
msg catched message when error raised about geometry
Emmanuel Blondel [email protected]
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp) clgeo_SummaryReport(report)
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp) clgeo_SummaryReport(report)
Function to get the list of index of suspicious geometries within a spatial data
collection, given a spatial data collection report returned by the function
clgeo_CollectionReport
clgeo_SuspiciousFeatures(report, errors.only = NULL)
clgeo_SuspiciousFeatures(report, errors.only = NULL)
report |
a report object as returned by |
errors.only |
an object of class |
an object of class vector
giving the numeric indexes of spatial
objects tagged as suspicious (i.e. that are not valid acccording to OGC
specifications)
Emmanuel Blondel [email protected]
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp) nv <- clgeo_SuspiciousFeatures(report)
require(sf) file <- system.file("extdata", "example.shp", package = "cleangeo") sf <- sf::st_read(file) sp <- as(sf, "Spatial") report <- clgeo_CollectionReport(sp) nv <- clgeo_SuspiciousFeatures(report)