Generate sf objects (1)
First let’s start at a higher level: we already have a data object.
Conversion can then be done with st_as_sf()
.
Suppose we have a data frame with point coordinates, and we know that the CRS is EPSG:4326
.
d <- tibble(
place = c("London", "Paris", "Madrid", "Rome"),
long = c(-0.118092, 2.349014, -3.703339, 12.496366),
lat = c(51.509865, 48.864716, 40.416729, 41.902782),
value = c(200, 300, 400, 500))
d
## # A tibble: 4 × 4
## place long lat value
## <chr> <dbl> <dbl> <dbl>
## 1 London -0.118 51.5 200
## 2 Paris 2.35 48.9 300
## 3 Madrid -3.70 40.4 400
## 4 Rome 12.5 41.9 500