How can geometry set
objects be converted to simple features collection
objects with the package sf
in R? I want to add attribute data to the geometry but am prevented from doing so because geometry set
excludes including data.
Converting simple features collection
to geometry set
is done using st_geometry
, but what is the equivalent in reverse? See sample code below:
#load sample data set
nc <- st_read(system.file("shape/nc.shp", package="sf"))
#Simple feature collection with 100 features and 14 fields
#geometry type: MULTIPOLYGON
#etc
#convert to geometry collection
nc_geom<-st_geometry(nc)
#Geometry set for 100 features
#geometry type: MULTIPOLYGON
#etc
Best Answer
I think you want to create a spatial data frame with
st_sf
:Then you can add extra columns: