我正在尝试将 shapefile 应用到 ggmaps 地图,但它给了我非常奇怪的结果。有问题的形状文件是澳大利亚统计局提供的“统计本地区域”(类似于邮政编码的组)形状文件here.
Normally I might think that it's a problem of cut off edge points, but I'm hitting it even at zoom level 1 (in fact it looks even worse):
这是我用来生成上面图表的一些代码:
library(tidyverse)
library(ggmap)
library(rgdal)
slas <- readOGR(dsn="SLA",layer="SLA11aAust")
aus4 <- get_map("Australia",zoom=4)
ggmap(aus4)
ggmap(aus4)+
geom_polygon(data=slas, aes(x=long,y=lat))
aus1 <- get_map("Australia",zoom=1)
ggmap(aus1)
ggmap(aus1)+
geom_polygon(data=slas, aes(x=long,y=lat))
我是否做错了什么,或者 shapefile 是否以某种方式配置不正确?
我认为你只需要(可选)fortify
变量slas
,别忘了group
并用颜色使边界可见:
slas <- fortify(slas, region = "SLA_CODE11")
ggmap(aus4) +
geom_polygon(data = slas2, color = "white", aes(x = long, y = lat, group = group))
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)