从spData::world数据获取每个国家的中点坐标

从spData::world数据获取每个国家的中点坐标,r,ggplot2,maps,R,Ggplot2,Maps,我正在使用spData中的world数据集绘制地图,如下所示: 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

我正在使用
spData
中的
world
数据集绘制地图,如下所示:

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…

我还想为每个国家绘制一个标签,最好在每个国家的Lat/Long中点
spData::world
data.frame。我假定这是从
geom
字段中完成的,但我不知道如何获得它。

一种可能的方法,无需明确确定质心;尽管地图有点拥挤

库(spData)
图书馆(GG2)
图书馆(sf)
ggplot(世界)+
几何图形(aes(几何图形=几何图形))+
geom_sf_文本(aes(标签=名称长),大小=1.5)

由(v2.0.0)于2021年4月13日创建

spData::world %>% ggplot() + geom_sf(aes(geometry=geom))