问题描述
我现在设法在R中获得了相当不错的中国地图,并且已经设法使用来自两个单独的csv文件的geom_points在其上绘制了一些空间数据。我认为有一种方法可以将所有要点集中在一个文件中并对其进行排序,但是我还没有得到进一步的改进。
我需要将这些点变成凸包。我已经尝试过在线执行以下步骤,但我无法理解。这是我的代码:
#import data
sus_scrofa_lp <- read.csv(fileEncoding="UTF-8-BOM","C:/PhD/data/s-scrofa_lp.csv")
sus_scrofa_ho <- read.csv(fileEncoding="UTF-8-BOM","C:/PhD/data/s-scrofa_ho.csv")
#create a map of china - start
library(maptools)
china_map1 <-readOGR(dsn="C:/PhD/data/bou2_4p.shp")
#SpatialpolygonsDataFrame
class(china_map1)
length(china_map1)
china_map2 <- china_map1@data
head(china_map2)
library(ggplot2)
china_map3 <- fortify(china_map1)
head(china_map3)
china_map2$NAME <- iconv(china_map2$NAME,from = 'GBK') #the original coding format is GBK
#create a map of china - end
ggplot(china_map1,aes(x = long,y = lat,group = group)) +
geom_path(color="grey40") +
geom_polygon(fill = 'beige') +
geom_point(data=sus_scrofa_lp,aes(lon,lat),inherit.aes = FALSE,alpha = 0.5,size = 0.5,color ="red") +
geom_point(data=sus_scrofa_ho,color ="blue") + coord_equal()
这就是我所拥有的:points plotted on map
这是s-scrofa_ho.csv https://www.dropbox.com/s/0w6iqlky5cbipch/s-scrofa_ho.csv?dl=0
的数据这是s-scrofa_lp.csv https://www.dropbox.com/s/sr49y94rby0o1sm/s-scrofa_lp.csv?dl=0
的数据解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)