如何使用r创建世界街道地图?

如何使用r创建世界街道地图?,r,ggplot2,maps,spatial,R,Ggplot2,Maps,Spatial,我想用Rstudio创建一张世界街道地图。我有以下代码: countries_map <-map_data("world") world_map<-ggplot() + geom_map(data = countries_map, map = countries_map,aes(x = long, y = lat, map_id = region, group = group), fill = "light blue", color

我想用Rstudio创建一张世界街道地图。我有以下代码:

countries_map <-map_data("world")
world_map<-ggplot() + 
  geom_map(data = countries_map, 
           map = countries_map,aes(x = long, y = lat, map_id = region, group = group),
           fill = "light blue", color = "black", size = 0.1)

countries\u map我们可以使用
传单
套餐。请参阅此链接以了解底图()的选择。在这里,我使用了“Esri.WorldStreetMap”,它与您的示例图像所示相同

library(leaflet)
leaflet() %>%
  addProviderTiles(provider = "Esri.WorldStreetMap") %>%
  setView(0, 0, zoom = 1)

除了
传单
,这里我还介绍了另外两个用于创建交互式地图的软件包,它们是
tmap
mapview

library(sf)
library(leaflet)
library(mapview)
library(tmap)

# Gett the World sf data
data("World")

# Turn on the view mode in tmap
tmap_mode("view")

# Plot World using tmap
tm_basemap("Esri.WorldStreetMap") +
tm_shape(World) +
  tm_polygons(col = "continent")

更新

下面是一种使用
tmap
包向每个多边形添加文本的方法

library(sf)
library(leaflet)
library(mapview)
library(tmap)

# Gett the World sf data
data("World")

# Turn on the view mode in tmap
tmap_mode("plot")

# Plot World using tmap
tm_basemap("Esri.WorldStreetMap") +
  tm_shape(World) +
  tm_polygons() +
  tm_text(text = "iso_a3")

如果必须使用
ggplot2
,可以将数据准备为
sf
对象,并使用
geom\u sf
geom\u sf\u text
,如下所示

library(sf)
library(tmap)
library(ggplot2)

# Gett the World sf data
data("World")

ggplot(World) +
  geom_sf() +
  geom_sf_text(aes(label = iso_a3))

谢谢你的回答。有一个选项可以在没有交互式地图的情况下创建地图?只看到标有国家名称等的地图。。?谢谢大家!@LiranBenZion你要的底图是一个典型的在线交互设置,所以你要的是令人困惑的。好的,我明白了。我将试着解释我自己:在我的代码中,我看到了没有名字的世界地图。我试着看有名字的地图,可能吗?谢谢@利兰本辛很乐意帮忙。如果我的帖子解决了你的问题,请接受它作为答案。
library(sf)
library(tmap)
library(ggplot2)

# Gett the World sf data
data("World")

ggplot(World) +
  geom_sf() +
  geom_sf_text(aes(label = iso_a3))