1 | initial version |
To obtain a flattened data frame from the sgbp object produced by the geosbinarypred {sf} function, specifically st_equals, you can use the following process:
Here is an example code snippet that demonstrates this process:
library(sf)
# Load example data
nc <- st_read(system.file("shape/nc.shp", package="sf"))
# Find intersecting geometries
intersects <- st_intersects(nc, nc)
# Create sgbp object for intersecting geometries
sgbp <- st_binary(intersects)
# Find equal geometries with sgbp object
equals <- st_equals(sgbp)
# Collapse sgbp object to list of geometries
clusters <- st_collapse(equals)
# Convert list of geometries to sf object
sf_clusters <- st_as_sf(clusters, crs = 4267)
# Convert sf object to data frame
df_clusters <- as.data.frame(sf_clusters)
This will give you a flattened data frame with cluster IDs and the original data attributes.