st_combine by variables R

Using st_combine() by Variables in R

library(sf)

# Create a simple feature (sf) object
nc <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)

# Combine geometries by a variable
nc_combined <- st_combine(nc["NAME"])

# Print the combined object
nc_combined
  1. Load the sf Package
library(sf)
  1. Create a Simple Feature (sf) Object
nc <- st_read(system.file("shape/nc.shp", package="sf"), quiet = TRUE)
  1. Combine Geometries by a Variable
nc_combined <- st_combine(nc["NAME"])
  1. Print the Combined Object
nc_combined