我一直在尝试将绘图内容(线条/多边形)导出为可以在ArcMap中打开的图层/shapefile文件。这些是我一直在使用的一些库:
library(shapefiles) library(PBSmapping) library(adehabitatHR) library(maptools) library(maps) library(rgdal) library(igraph)
我的纬度/经度数据长这样:
我使用AdehabitatHR包绘制了位置,并计算出最小凸多边形(MCP)。tagdata<-read.table(text="meanlat meanlong -18.63327 147.0248 -18.6368 147.0238 -18.62068 147.294 -18.62953 147.2942 -18.62953 147.2942 -18.62091 147.2938 -18.62953 147.2942 -18.62466 147.2926 -18.73393 147.2816 -18.73393 147.2816 -18.75383 147.2541 -18.75383 147.2541 -18.75383 147.2541 -18.75383 147.2541 -18.6368 147.0238 -18.63063 147.0256 -18.63063 147.0256 -18.68133 147.1164 -18.6368 147.0238 -18.63063 147.0256 -18.63063 147.0256 -18.75383 147.2541 -18.61273 147.0682 -18.69655 147.09 -18.6368 147.0238 -18.63063 147.0256 -18.63063 147.0256 -18.63217 147.0251 -18.75383 147.2541 -18.75383 147.2541 -18.75383 147.2541 -18.63063 147.0256 -18.68133 147.1164 -18.68133 147.1164 -18.63217 147.0251 -18.69922 147.0909 -18.73393 147.2816 -18.63632 147.0792 -18.69522 147.0896 -18.6368 147.0238 -18.75383 147.2541 -18.75383 147.2541 -18.75383 147.2541",header=TRUE)
plot(tagdata$meanlong,tagdata$meanlat, col="red",pch=1)
loc<-tagdata[ ,c("meanlong","meanlat")]
coord<-SpatialPoints(loc)
poly<-mcp(coord,percent=100)
plot(poly,add=TRUE)
我知道如何将点导出/写入为Shapefile格式,可以在ArcMap或类似的软件中打开。
例如:
loc<-SpatialPoints(loc) # #convert loc to spatial points
rem<-tagdata[c(-1:-2)]
SpatialPointsDataFrame(coords=loc,data=rem)
obj<-SpatialPointsDataFrame(coords=loc,data=rem)
writePointsShape(obj,"myshape.shp")
然而,我并没有找到一种好的方法来处理多边形或折线对象。我希望能够将MCP中的poly对象导出/写入为shapefile格式。有什么建议吗?
rgdal
writeOGR
- mnel