7  Exercise

  1. Write the code to obtain the following plot.
shape <- st_read(system.file("shape/nc.shp", package="sf")) # included with sf package

cities <- data.frame(name = c("Raleigh", "Greensboro", "Wilmington"),
                     x = c(-78.633333, -79.819444, -77.912222),
                     y = c(35.766667, 36.08, 34.223333))
Reading layer `nc' from data source 
  `C:\Users\DELL\AppData\Local\R\win-library\4.5\sf\shape\nc.shp' 
  using driver `ESRI Shapefile'
Simple feature collection with 100 features and 14 fields
Geometry type: MULTIPOLYGON
Dimension:     XY
Bounding box:  xmin: -84.32385 ymin: 33.88199 xmax: -75.45698 ymax: 36.58965
Geodetic CRS:  NAD27