Note the additional arguments such as coords and crs. Here we use the crs of 4326.
Let us now check the class of the newly created snow_deaths_sf object.
snow_deaths_sf |>class()
[1] "sf" "data.frame"
Note that the sf object is also a data.frame.
Let us look at the structure of the sf object.
snow_deaths_sf
Simple feature collection with 578 features and 1 field
Geometry type: POINT
Dimension: XY
Bounding box: xmin: 8.280715 ymin: 6.090047 xmax: 17.93893 ymax: 16.97276
Geodetic CRS: WGS 84
First 10 features:
case geometry
1 1 POINT (13.58801 11.0956)
2 2 POINT (9.878124 12.55918)
3 3 POINT (14.65398 10.18044)
4 4 POINT (15.22057 9.993003)
5 5 POINT (13.16265 12.96319)
6 6 POINT (13.80617 8.889046)
7 7 POINT (13.10214 10.56081)
8 8 POINT (11.00403 11.86713)
9 9 POINT (15.15475 11.70451)
10 10 POINT (11.12639 9.643859)
Let us now visualise the deaths using the geom_sf() function.
snow_deaths_sf |>ggplot() +geom_sf()
ggplot() +geom_sf(data = snow_deaths_sf)
Let us now add color to the deaths using the color argument.
snow_deaths_sf |>ggplot() +geom_sf(color ='red')
Now, we can add additional layers such as the water pumps and the streets of Soho, London.