• geos_is_valid() returns a logical vector denoting if each feature is a valid geometry.

  • geos_is_valid_detail() returns a data frame with columns is_valid (logical), reason (character), and location (geos_geometry).

geos_is_valid(geom)

geos_is_valid_detail(geom, allow_self_touching_ring_forming_hole = FALSE)

Arguments

geom

A GEOS geometry vector

allow_self_touching_ring_forming_hole

It's all in the name

Examples

geos_is_valid(
  c(
    "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))",
    "POLYGON ((0 0, 1 1, 1 0, 0 1, 0 0))"
  )
)
#> [1]  TRUE FALSE

geos_is_valid_detail(
  c(
    "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))",
    "POLYGON ((0 0, 1 1, 1 0, 0 1, 0 0))"
  )
)
#>   is_valid            reason                   location
#> 1     TRUE              <NA> <GEOMETRYCOLLECTION EMPTY>
#> 2    FALSE Self-intersection          <POINT (0.5 0.5)>