Last active
November 6, 2023 15:57
-
-
Save NewGraphEnvironment/9e20702275c63bf6f15304944a85d535 to your computer and use it in GitHub Desktop.
Extract coordinates from `sf` spatial object and add to object as columns
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# asssumes UTMs. Column nmaes would be `lat` `long` if in Albers or WSG84 | |
#option 1 - retains the sf object | |
sf_object %>% | |
mutate( | |
easting = sf::st_coordinates(.)[,1], | |
northing = sf::st_coordinates(.)[,2]) | |
# option 2 - this changes from sf object to a dbl_df - not usually helpful | |
sf_object %>% | |
poisspatial::ps_sfc_to_coords(X = 'easting', Y = 'northing') | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment