【问题标题】:Remove country and city names from map从地图中删除国家和城市名称
【发布时间】:2021-05-13 01:05:48
【问题描述】:

使用ggmap 包,我通过生成地图

map <- get_map(location = c(10, 51), zoom = 6, maptype = "toner-lite", 
               scale = 1, color = "bw")
ggmap(map)

是否可以删除国家和城市名称,以及除国家以外的所有寄宿生吗?

【问题讨论】:

  • maptype = "toner-background" 看起来它可能会做你想做的事
  • 只能使用不同的瓷砖。每组地图图块都是固定的,因此您无法更改显示的内容。 Stamen 提供了其他图块,或者您可以在 Google 地图中使用自定义样式。第二个选项有点棘手,但上面有一些帖子,包括this 一个。
  • @Chris "toner-background" 仍然显示道路,我希望水不显示为黑色。
  • @camille 似乎没有可以实现我所寻找的雄蕊瓷砖组。我会研究谷歌地图选项。

标签: r ggmap


【解决方案1】:

您可以通过更改 terrain-background 地图的不透明度和更改 ggplot 中的一些主题元素来相当接近。

map <- get_map(location = c(10, 51), zoom = 6, maptype = "toner-background", 
               scale = 1, color = "bw")

# change opacity of basemap
mapatt <- attributes(map)
map_transparent <- matrix(adjustcolor(map, alpha.f = 0.2), nrow = nrow(map))
attributes(map_transparent) <- mapatt

ggmap(map_transparent) + 
  theme(panel.grid = element_blank(), panel.background = element_rect(fill = 'white'))

【讨论】:

    【解决方案2】:

    如果您有启用结算功能的 Google Maps API 密钥,您可以尝试:

    代码

    map <- get_googlemap(c(10, 51), zoom = 6, scale = 1, style = s)
    ggmap(map)
    

    数据

    s <- "element:geometry%7Ccolor:0xf5f5f5&style=element:labels%7Cvisibility:off&style=element:labels.icon%7Cvisibility:off&style=element:labels.text.fill%7Ccolor:0x616161&style=element:labels.text.stroke%7Ccolor:0xf5f5f5&style=feature:administrative%7Celement:geometry%7Cvisibility:off&style=feature:administrative.country%7Celement:geometry.stroke%7Ccolor:0x000000%7Cvisibility:on&style=feature:administrative.land_parcel%7Cvisibility:off&style=feature:administrative.land_parcel%7Celement:labels.text.fill%7Ccolor:0xbdbdbd&style=feature:administrative.neighborhood%7Cvisibility:off&style=feature:poi%7Cvisibility:off&style=feature:poi%7Celement:geometry%7Ccolor:0xeeeeee&style=feature:poi%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:poi.park%7Celement:geometry%7Ccolor:0xe5e5e5&style=feature:poi.park%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&style=feature:road%7Cvisibility:off&style=feature:road%7Celement:geometry%7Ccolor:0xffffff&style=feature:road%7Celement:labels.icon%7Cvisibility:off&style=feature:road.arterial%7Celement:labels.text.fill%7Ccolor:0x757575&style=feature:road.highway%7Celement:geometry%7Ccolor:0xdadada&style=feature:road.highway%7Celement:labels.text.fill%7Ccolor:0x616161&style=feature:road.local%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&style=feature:transit%7Cvisibility:off&style=feature:transit.line%7Celement:geometry%7Ccolor:0xe5e5e5&style=feature:transit.station%7Celement:geometry%7Ccolor:0xeeeeee&style=feature:water%7Celement:geometry%7Ccolor:0xc9c9c9&style=feature:water%7Celement:labels.text.fill%7Ccolor:0x9e9e9e&size=480x360"
    # Generated on https://mapstyle.withgoogle.com/
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-06-30
      • 2019-10-27
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-03-07
      • 1970-01-01
      相关资源
      最近更新 更多