Description Usage Arguments Examples
Utilities for 'sf'
1 | coordinates_to_column(x, col_names = NULL, fun = sf::st_centroid)
|
x |
sf object. |
col_names |
Column names. |
fun |
Function to calcuate POINT from the geometry. |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | points_sfc <- sf::st_sfc(
sf::st_point(c(1, 1)),
sf::st_point(c(2, 2))
)
points_sf <- sf::st_sf(
value = c(10, 20),
geometry = points_sfc
)
# For POINT, add the coordinates of the points.
coordinates_to_column(points_sf)
coordinates_to_column(points_sf, col_names = c("long", "lat"))
# For other features, add the coordinates of the centroids of them.
nc <- sf::st_read(system.file("shape/nc.shp", package = "sf"), quiet = TRUE)
nc_3857 <- sf::st_transform(nc, 3857)
coordinates_to_column(nc_3857)
# You can specify other functions that return one POINT per geometry.
coordinates_to_column(nc_3857, fun = sf::st_point_on_surface)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.