簡體   English   中英

嘗試在 R 中將空間多邊形導出為 shapefile 時 writeOGR 出錯

[英]Error in writeOGR when trying to export spatial polygons as shapefile in R

我正在嘗試導出我為家庭范圍數據創建的多邊形,但是當我 go 導出它們時收到此錯誤消息:

Error in writeOGR(colkud95[1, ], ".", "colonyhomerange", driver = "ESRI Shapefile") : 
  Spatial Polygons objects should have valid ordering comments
use rgeos::createSPComment()
dput(HRtracks[1:10, ])
new("SpatialPointsDataFrame", data = structure(list(TripID = c(1, 
1, 1, 1, 1, 1, 1, 1, 1, 1), `Breeding stage` = c(1, 1, 1, 1, 
1, 1, 1, 1, 1, 1)), row.names = c(NA, -10L), class = c("tbl_df", 
"tbl", "data.frame")), coords.nrs = 1:2, coords = structure(c(174.78327, 
174.78326, 174.78332, 174.78323, 174.78325, 174.78277, 174.78238, 
174.78238, 174.78244, 174.78278, -41.09482, -41.09491, -41.09484, 
-41.09491, -41.09496, -41.09564, -41.09637, -41.09685, -41.09747, 
-41.09771), .Dim = c(10L, 2L), .Dimnames = list(NULL, c("x", 
"y"))), bbox = structure(c(174.78238, -41.09771, 174.78332, -41.09482
), .Dim = c(2L, 2L), .Dimnames = list(c("x", "y"), c("min", "max"
))), proj4string = new("CRS", projargs = "+proj=merc +a=6378137 +b=6378137 +lat_ts=0 +lon_0=0 +x_0=0 +y_0=0 +k=1 +units=m +nadgrids=@null +wktext +no_defs"))

#main package for this analysis
library(adehabitatHR)  
library(sp)
library(readxl)
library(rgdal)

HRtracks<-read_excel("allinterpolatedtracks.xlsx") 
coordinates(HRtracks)<-c("x","y") 
proj4string(HRtracks)<- CRS("+init=epsg:3857")
#Organising variable 1 refers to Trip ID
colkud<-kernelUD(tracks.utm[,1],h="href", grid=1000,same4all=T)
#Organising variable 2 refers to Breeding stage
colkudb<-kernelUD(tracks.utm[,2],h="href", grid=1000,same4all=T)
kernel.area(colkud,percent=50)
kernel.area(colkudb,percent=50)
kernel.area(colkud,percent=95)
kernel.area(colkudb,percent=95)
colkud95<- getverticeshr(colkud, percent=95)
colkud95b<- getverticeshr(colkudb, percent=95)
colkud50b<- getverticeshr(colkudb, percent=50)
colkud50<- getverticeshr(colkud, percent=50)
#This is where the error occurs
writeOGR(colkud95,".",layer="colkud95",driver="ESRI Shapefile")

我沒有任何運氣來尋找這個問題的答案,我的目標是為家庭范圍創建多邊形,然后將它們導出為要在 QGIS 中使用的 shapefile。

安裝 rgeos package 也為我解決了這個問題。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM