R: Check polygon validity

is.valid {terra} | R Documentation

## Check polygon validity

### Description

Check the validity of polygons

### Usage

    ## S4 method for signature 'SpatVector'
    is.valid(x, messages=FALSE)

### Arguments

`x` | SpatVector
`messages` | logical. If `TRUE` the error messages are returned

### Value

logical

### Examples

    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")

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

[Package terra version 1.2-10 Index]