st_prepair repairs single polygons according to the international standards ISO 19107 using a constrained triangulation approach.

st_prepair(x, algorithm = c("oddeven", "setdiff"), min_area = 0)

Arguments

x

object of class sf, sfc or sfg, it only works POLYGON or MULTIPOLYGON are supported

algorithm

character; algorithm used to repair the polygon. oddeven (default) or setdiff. More on these two algorithm details.

min_area

numeric; all polygons with areas smaller than min_area will be removed.

Value

an object of class sf, sfc or sfg depending on whether the input is respectively sf, sfc or sfg

Details

st_prepair supports two algorithms:

  • oddeven: an extension of the odd-even algorithm to handle GIS polygons containing inner rings and degeneracies;

  • setdiff: one where we follow a point set difference rule for the rings (outer - inner).

References

Ledoux, H., Arroyo Ohori, K., and Meijers, M. (2014). A triangulation-based approach to automatically repair GIS polygons. Computers & Geosciences 66:121–131.

van Oosterom P., Quak W., Tijssen T. (2005). About Invalid, Valid and Clean Polygons. In: Developments in Spatial Data Handling. Springer, Berlin, Heidelberg

See also

sf::st_make_valid for another approach to fix broken polygons

Examples

if (FALSE) { library(sf) p1 <- st_as_sfc("POLYGON((0 0, 0 10, 10 0, 10 10, 0 0))") st_is_valid(p1) st_prepair(p1) st_is_valid(st_prepair(p1)) }