terra (version 1.7-71)

is.valid: Check or fix polygon or extent validity

Description

Check the validity of polygons or attempt to fix it. Or check the validity of a SpatExtent.

Usage

# S4 method for SpatVector
is.valid(x, messages=FALSE, as.points=FALSE)

# S4 method for SpatVector makeValid(x)

# S4 method for SpatExtent is.valid(x)

Value

logical

Arguments

x

SpatVector or SpatExtent

messages

logical. If TRUE the error messages are returned

as.points

logical. If TRUE, it is attempted to return locations where polygons are invalid as a SpatVector or points

See Also

topology

Examples

Run this code
w <- vect("POLYGON ((0 -5, 10 0, 10 -10, 0 -5))")
is.valid(w)

w <- vect("POLYGON ((0 -5, 10 0, 10 -10, 4 -2, 0 -5))")
is.valid(w)
is.valid(w, TRUE)

plot(w)
points(cbind(4.54, -2.72), cex=2, col="red")


e <- ext(0, 1, 0, 1)
is.valid(e)

ee <- ext(0, 0, 0, 0)
is.valid(ee)

Run the code above in your browser using DataLab