This function identifies polygons that intersect in some way. Its main use is
to identify sites within a data set that cover the same or similar area, and
could be considered a single site. A cluster identifier (.cluster
) is
assigned to each polygon, with intersecting polygons identified by a common
.cluster
id.
Examples
data("thylacine_data")
# Generate some interseting polygons
thylacine_polygons <-
thylacine_data |>
dplyr::group_by(trap) |>
dplyr::slice(1) |>
sf::st_as_sf(coords = c("longitude_dd", "latitude_dd"), crs = "EPSG:4326") |>
sf::st_buffer(dist = 5000) |>
dplyr::select(site, trap, geometry) |>
dplyr::ungroup()
# Run function
dwc_polygon_cluster(thylacine_polygons)
#> Simple feature collection with 4 features and 3 fields
#> Geometry type: POLYGON
#> Dimension: XY
#> Bounding box: xmin: 144.9178 ymin: -43.30659 xmax: 146.766 ymax: -41.12926
#> Geodetic CRS: WGS 84
#> # A tibble: 4 × 4
#> site trap geometry .cluster
#> * <chr> <chr> <POLYGON [°]> <int>
#> 1 Picton Picton 1 ((146.6416 -43.26181, 146.641 -43.26223, 146.6414 -4… 2
#> 2 Picton Picton 2 ((146.6377 -43.24986, 146.6372 -43.2503, 146.6385 -4… 2
#> 3 Sumac Sumac 1 ((144.9433 -41.21162, 144.944 -41.21187, 144.9447 -4… 1
#> 4 Sumac Sumac 2 ((144.929 -41.22172, 144.9284 -41.22212, 144.9292 -4… 1