Make invalid geometries valid
Function returns a valid geometry, not available before GEOS 3.8.0
gMakeValid(spgeom, byid=FALSE, id = NULL)
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. |
Returns a valid geometry or collection of geometries of different types
Roger Bivand
# 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")) }
Please choose more modern alternatives, such as Google Chrome or Mozilla Firefox.