Is there an sf-native (i.e. “correct”) way of extracting everything except the geometry column from a simple features object? This works
df but the select( , -geometry) step feels unnecessary. Also, it doesn”t remove the geometry attributes.
Đang xem: Sf geometry column
Set the st_geometry property to NULL.
library(sf)nc Also (though this won”t remove the attr(nc, “sf_column”):
To drop the geometry column, use st_drop_geometry():
library(sf)nc % st_drop_geometry()class(nc_df2)#> <1> “data.frame”Before st_drop_geometry() was added to the sf package (in November, 2018), one could produce the same result using the st_set_geometry() function, like this:
library(sf)nc <1> “sf” “data.frame”nc_df % st_set_geometry(NULL)class(nc_df)#> <1> “data.frame”
df Or just df<,-geometry_column> if you don”t want to create new object
df – your object
geometry_column – column where geometry is stored
Thanks for contributing an answer to Geographic Information Systems Stack Exchange!
Please be sure to answer the question. Provide details and share your research!
But avoid …
Asking for help, clarification, or responding to other answers.Making statements based on opinion; back them up with references or personal experience.
To learn more, see our tips on writing great answers.
Post Your Answer Discard
Not the answer you're looking for? Browse other questions tagged r sf or ask your own question.
How do I use a Simple Feature Collection (sfc) from the sf package with the elevatr package to load elevation data?
site design / logo © 2021 Stack Exchange Inc; user contributions licensed under cc by-sa. rev2021.8.2.39897