首页 > 解决方案 > 使用 ggplot2 绘制地图

问题描述

我正在尝试使用此代码在瑞士地图上绘制数据

require("rgdal")
require("maptools")
require("ggplot2")
require("plyr")
require("maps")
require("ggmap")

ggplot() + geom_polygon(data = da, aes(x=long, y = lat)) + 
coord_fixed(1.3)+
geom_point(data=de, aes(x=lat, y=lon), color="orange") 

其中 data da 是使用 swissmap 包的地图:

 da<- shp_df[[6]]

& 数据是:

'data.frame':   115 obs. of  5 variables:
 $ FB    : Factor w/ 3 levels "I","II","IV": 2 2 2 3 1 2 1 3 1 1
 $ Nom   : Factor w/ 115 levels "\"Patient Education\" Programm unipolare Depression",..: 9 31 95 112 92 41 70 84 13 21 ...
 $ lon  : num  7.36 8.54 7.08 NA 7.45 ...
 $ lat  : num  46.2 47.4 46.1 NA 46.9 ...
 $ Coûts: int  100000 380000 150000 300000 2544000 300000 1897000 500000 2930000 2400000 ...

我得到了这个结果。在此处输入图像描述 这不是我想要的,我试图在位置(有时是同一个地方)绘制数据集中的数据。任何帮助或建议将不胜感激。谢谢你

标签: rdictionaryggplot2ggmapmaptools

解决方案


推荐阅读