首页 > 解决方案 > 使用 geojson 文件干扰 R 地图

问题描述

我从这个链接下载了 GeoJSON 文件:https ://public.opendatasoft.com/explore/dataset/contours-iris/export/

我绘制它,但我有一个干涉多边形 interference_polygon_picture

但是在网站上,它显示了多边形并且没有这个多边形: https ://public.opendatasoft.com/explore/dataset/contours-iris/map/?q=gers&location=13,43.65999,0.5815&basemap=jawg .streets

我曾经尝试使用另一个网站的 shx 中的另一个文件进行映射,但我在同一个城镇附近遇到了同样的问题(Auch)

我怎样才能删除它?我的 R 代码有问题吗?

谢谢您的帮助

iris.poly2 <- readOGR(dsn="contours-iris.geojson", "OGRGeoJSON")

ggplot()  + 
  geom_polygon(data=iris.poly2, aes(x=long, y=lat, group=id), color="grey", size=0.1) +
  coord_map(xlim=c(0.4627843, 0.6773605), 
            ylim=c(43.58996 , 43.72575) ) 

标签: rggplot2rgdalcartography

解决方案


group=id通过替换解决group=group

ggplot()  + 
  geom_polygon(data=iris.poly2, aes(x=long, y=lat, group=group), color="grey", size=0.1) +
  coord_map(xlim=c(0.4627843, 0.6773605), 
            ylim=c(43.58996 , 43.72575) ) 

group=id在 3 个多边形之间创建了一个链接 => 干涉多边形


推荐阅读