【问题标题】:Plotting to shapefile region with ggplot / ggmap使用 ggplot / ggmap 绘制到 shapefile 区域
【发布时间】:2016-01-14 19:48:58
【问题描述】:

我有一个显示英格兰地图的 shapefile,上面标有区域:

England <- readOGR(dsn = "...")

England.fort <- fortify(England, region='regionID') 
England.fort <-England.fort[order(England.fort$order), ] 

给我England.fort:

England.fort
>long
>lat
>order
>hole
>piece
>id      #contains the region IDs
>group   #contains the region IDs
>Total   #I want to plot this

来自此处的形状文件:https://geoportal.statistics.gov.uk/Docs/Boundaries/Local_authority_district_(GB)_2014_Boundaries_(Generalised_Clipped).zip

我想绘制显示每个区域总人数的区域:

p <- ggplot(data=England.fort, aes(x=long, y=lat, group=group, fill="Total")) + 
     geom_polygon(colour='black', fill='white') + theme_bw()

但它给了我一张英格兰以外的空白地图,所有地区都是白色的。

【问题讨论】:

  • 我尝试了 fortify 命令,它创建了一个没有引用回区域 ID (LAD14D) 的数据框,所以我无法将总数链接到它
  • 其实我认为这个链接可以解决你提到的问题!
  • 不知道该说什么:)..但你可以删除 scale_fill_brewer("Total") 来测试你的其余代码
  • 您可以尝试为未来的读者发布答案

标签: r plot mapping gis


【解决方案1】:
ggplot(data=England.fort, aes(x=long, y=lat, group=group, Fill=Total)) + 
          geom_polygon() +
          theme_bw()

成功了。谢谢

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2018-11-11
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-06-22
    • 1970-01-01
    • 2018-07-24
    相关资源
    最近更新 更多