Become an expert in R — Interactive courses, Cheat Sheets, certificates and more!
Get Started for Free

topo-unary-gMakeValid

Make invalid geometries valid


Description

Function returns a valid geometry, not available before GEOS 3.8.0

Usage

gMakeValid(spgeom, byid=FALSE, id = NULL)

Arguments

spgeom

sp object as defined in package sp

byid

Logical determining if the function should be applied across subgeometries (TRUE) or the entire object (FALSE)

id

Character vector defining id labels for the resulting geometries, if unspecified returned geometries will be labeled based on their parent geometries' labels.

Details

Returns a valid geometry or collection of geometries of different types

Author(s)

Roger Bivand

See Also

Examples

# Based on test geometries from sf
run <- FALSE
if (version_GEOS0() >= "3.8.0") run <- TRUE
if (run) {
X <- readWKT("POLYGON ((0 0, 0.5 0, 0.5 0.5, 0.5 0, 1 0, 1 1, 0 1, 0 0))")
gIsValid(X)
}
if (run) {
class(X)
}
if (run) {
row.names(X)
}
if (run) {
Y <- gMakeValid(X)
}
if (run) {
gIsValid(Y)
}
if (run) {
class(Y)
}
if (run) {
plot(slot(Y, "polyobj"))
plot(slot(Y, "lineobj"), add=TRUE, col="red")
}
if (run) {
row.names(slot(Y, "polyobj"))
}
if (run) {
row.names(slot(Y, "lineobj"))
}

rgeos

Interface to Geometry Engine - Open Source ('GEOS')

v0.5-5
GPL (>= 2)
Authors
Roger Bivand [cre, aut] (<https://orcid.org/0000-0003-2392-6140>), Colin Rundel [aut], Edzer Pebesma [ctb], Rainer Stuetz [ctb], Karl Ove Hufthammer [ctb], Patrick Giraudoux [ctb], Martin Davis [cph, ctb], Sandro Santilli [cph, ctb]
Initial release
2020-09-01

We don't support your browser anymore

Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.