Empty geometries

  • arise naturally with geometrical operations
  • vanish when we include non-empty geometries
library(sf) |> suppressPackageStartupMessages()
p1 <- st_point(c(0,0))
p2 <- st_point(c(1,1))
(e <- st_intersection(p1, p2))
## GEOMETRYCOLLECTION EMPTY

Example of non-empty when using st_intersect()

## Notice that the intersection now does not show an empty geometry 
(i <- st_intersection(s))
## Geometry set for 3 features 
## Geometry type: POLYGON
## Dimension:     XY
## Bounding box:  xmin: 0.2122312 ymin: 0.5126494 xmax: 2.471491 ymax: 2.750237
## CRS:           NA
## POLYGON ((2.471491 2.512649, 2.471491 0.5126494...
## POLYGON ((0.4714915 2.512649, 2.212231 2.512649...
## POLYGON ((0.2122312 0.7502374, 0.2122312 2.7502...