0
我正在R上運行我的數據(稱爲Ade)的MCP(家庭範圍)分析,這是一組用於動物位置的GPS點。錯誤消息xy應該是類SpatialPoints
我跑到下面的腳本:
Ade <- read.csv("Ade.csv")
#Get the folder SP that is used to convert the data
library(sp)
#Convert
Ade <- matrix(runif(1564), ncol=2)
head (Ade)
Ade <- data.frame(Ade)
#Convert Ade to spatial points data frame by first ...
#Tell R that the coordinates are in the column X and column Y
coords <- SpatialPoints(Ade[, c("X", "Y")])
AdeSpat <- SpatialPointsDataFrame(coords, Ade)
#Specify the coordinate reference system of the data
proj4string(AdeSpat) <- CRS("+proj=XY +ellps=WGS84")
#View data
getClass(AdeSpat)
class(AdeSpat)
head (AdeSpat)
#Two steps in loading AdehabitatHR into R
install.packages("adehabitatHR")
library(adehabitatHR)
#Run MCP
mcp <- mcp(AdeSpat$coordinates, percent=95, unin = c ("km"), unout = c("km2"))
但是當我運行此我得到以下錯誤信息:
Error in mcp(AdeSpat$coordinates, percent = 95, unin = c("km"), unout =
c("km2")) : xy should be of class SpatialPoints
有人能向我解釋這是什麼意思,我怎麼能解決該問題,我已經在互聯網上搜索,但無法找到任何錯誤的答案「xy應該是類SpatialPoints」。
當我檢查數據幀我得到以下輸出:
> class(AdeSpat)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"
> head (AdeSpat)
coordinates ID ZONE X Y
1 (370984, 9752290) 1 36 M 370984 9752293
2 (370980, 9752290) 2 36 M 370980 9752288
3 (370980, 9752290) 3 36 M 370980 9752288
4 (370995, 9752290) 4 36 M 370995 9752287
5 (370995, 9752290) 5 36 M 370995 9752287
6 (371032, 9752310) 6 36 M 371032 9752312
Coordinate Reference System (CRS) arguments: +proj=XY +ellps=WGS84
謝謝Ĵ