【问题标题】:Plotting map for UK, in ggmap & ggplot2在 ggmap 和 ggplot2 中为英国绘制地图
【发布时间】:2021-03-19 05:26:02
【问题描述】:

全部,

如果

Germany = map_bounds <- c(left = 5, bottom = 47, right = 16, top = 56)

什么是英国?

英国 =

【问题讨论】:

  • 这些看起来不像 E 度和 N 度吗?
  • 如何将地图固定到英国,一定有比猜测坐标更简单的方法

标签: r ggplot2 ggmap


【解决方案1】:

尝试以下任一选项:

library(maps)       
library(mapdata)    
#Option 1
map('worldHires',
    c('UK', 'Ireland', 'Isle of Man','Isle of Wight'),
    xlim=c(-11,3), ylim=c(49,60.9)) 

输出:

或者:

library(ggplot2)
library(maps)
#Data
worldmap = map_data('world')
#Option 2
ggplot() + geom_polygon(data = worldmap, 
                        aes(x = long, 
                            y = lat, 
                            group = group,
                            ),
                        fill = 'gray90', 
                        color = 'black') + 
  coord_fixed(xlim = c(-10,3), 
              ylim = c(50.3, 59))

输出:

【讨论】:

  • 另外,如何使这个多边形的 alpha 值为 0.4? coords.map
  • @Dan 你已经回答了自己 :) 如果这个问题有助于考虑接受它stackoverflow.com/help/someone-answers 非常感谢!
【解决方案2】:

感谢上面的帮助,这里是几乎完整的代码,我只需要了解哪个位以及如何将热图多边形修改为透明,它们当前阻碍了下面的地图。

图书馆(ggplot2) 图书馆(ggmap) 库(RColorBrewer)

coords.data

-英国边界 map_bounds

coords.map

coords.map

-热图图层:根据坐标的相对频率填充颜色的多边形 coords.map

-填充密度轮廓 coords.map

-添加坐标,颜色为红色并定义形状 -形状:http://sape.inf.usi.ch/quick-reference/ggplot2/shape

coords.map

coords.map

【讨论】:

    【解决方案3】:

    除了@Duck 的答案之外,您还可以通过在epsg.io 上搜索该国家/地区来获得任何国家/地区的 WGS84(即经度和纬度)边界。

    例如,英国使用 British National Grid (EPSG 27700),因此如果您选择该投影,则会为您提供 WGS84 边界,您可以将其用于地图边界。

    WGS84 bounds:
    -8.82 49.79
    1.92 60.94 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2015-01-06
      • 1970-01-01
      • 2015-05-16
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-07-02
      • 1970-01-01
      相关资源
      最近更新 更多