I am plotting a map using the world
dataset from spData
, which looks as follows:
Simple feature collection with 6 features and 10 fields
Geometry type: MULTIPOLYGON
Dimension: XY
Bounding box: xmin: -180 ymin: -18.28799 xmax: 180 ymax: 83.23324
Geodetic CRS: WGS 84
# A tibble: 6 x 11
iso_a2 name_long continent region_un subregion type area_km2 pop lifeExp gdpPercap geom
<chr> <chr> <chr> <chr> <chr> <chr> <dbl> <dbl> <dbl> <dbl> <MULTIPOLYGON [°]>
1 FJ Fiji Oceania Oceania Melanesia Sovereign… 1.93e4 8.86e5 70.0 8222. (((180 -16.06713, 180 -16.55522, 179.3641 -16.8…
2 TZ Tanzania Africa Africa Eastern Afr… Sovereign… 9.33e5 5.22e7 64.2 2402. (((33.90371 -0.95, 34.07262 -1.05982, 37.69869 …
3 EH Western Sa… Africa Africa Northern Af… Indetermi… 9.63e4 NA NA NA (((-8.66559 27.65643, -8.665124 27.58948, -8.68…
4 CA Canada North Amer… Americas Northern Am… Sovereign… 1.00e7 3.55e7 82.0 43079. (((-122.84 49, -122.9742 49.00254, -124.9102 49…
5 US United Sta… North Amer… Americas Northern Am… Country 9.51e6 3.19e8 78.8 51922. (((-122.84 49, -120 49, -117.0312 49, -116.0482…
6 KZ Kazakhstan Asia Asia Central Asia Sovereign… 2.73e6 1.73e7 71.6 23587. (((87.35997 49.21498, 86.59878 48.54918, 85.768…
I have plotted the the outlines of each country using:
spData::world %>% ggplot() + geom_sf(aes(geometry=geom))
I would also like the plot a label for each country, preferably at the Lat/Long midpoint of each country spData::world
data.frame. I presume this is done from the geom
field, but I don't know how to obtain it.