我正在对我的数据(称为Ade)运行R中的MCP (home-range)分析,这是一组动物位置的GPS点。
我运行了以下脚本:
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 谢谢你J
发布于 2016-08-14 01:20:22
您必须直接放置包含您的空间点数据的对象。
在你的例子中,你的公式是:
mcp <- mcp(坐标,percent=95,unin =c ("km"),unout = c("km2"))
我希望它能对你有所帮助!
Murielle
https://stackoverflow.com/questions/38551215
复制相似问题