The function applies the implementation of the Douglas-Peuker algorithm for line generalization or simplification (originally from shapefiles) to objects inheriting from Spatial Polygons. It does not preserve topology, so is suitable for visualisation, but not for the subsequent analysis of the polygon boundaries, as artefacts may be created, and boundaries of neighbouring entities may be generalized differently. If the rgeos package is available,
thinnedSpatialPolyGEOS will be used with partial topology preservation instead of the R implementation here by passing arguments through.
thinnedSpatialPoly(SP, tolerance, minarea=0, topologyPreserve = FALSE, avoidGEOS = FALSE)
an object inheriting from the SpatialPolygons class
the tolerance value in the metric of the input object
the smallest area of Polygon objects to be retained, ignored if rgeos used
choose between two rgeos options: logical determining if the algorithm should attempt to preserve the topology (nodes not complete edges) of the original geometry
use R DP code even if rgeos is available
An object of the same class as the input object
Douglas, D. and Peucker, T. (1973). Algorithms for the reduction of the number of points required to represent a digitized line or its caricature. The Canadian Cartographer 10(2). 112-122.
Warnings reporting: Non-finite label point detected and replaced, reflect the changes in the geometries of the polygons induced by line generalization.
xx <- readShapeSpatial(system.file("shapes/sids.shp", package="maptools"), IDvar="FIPSNO", proj4string=CRS("+proj=longlat +ellps=clrk66"))#> Warning: readShapeSpatial is deprecated; use rgdal::readOGR or sf::st_read#> Warning: readShapePoly is deprecated; use rgdal::readOGR or sf::st_read#> Warning: Discarded datum Unknown based on Clarke 1866 ellipsoid in CRS definitionobject.size(as(xx, "SpatialPolygons"))#> 350544 bytesxxx <- thinnedSpatialPoly(xx, tolerance=0.05, minarea=0.001) object.size(as(xxx, "SpatialPolygons"))#> 374480 bytes