0

我对 R 相当陌生。我想使用 adehabitatHR 包从我的海龟 GPS 数据中创建内核密度和等值线。我遇到了一些问题……</p>

基本上我无法在 R 中分配 ID 和 XY 字段来创建 KD 和 MCP。

预先感谢您的任何帮助!

Here is what I have been doing...   

   
#loading packages
`library(adehabitatHR)
library(raster) 
library(rgdal)
library(maptools)`

#read CSV with UTM xy and ids

    track<- 
read.table("T:/GIS/Data/Tracking/state_space_model/20150210_AbHabiatatHRmodel/All_prelim_model_6hr_utm_forage_10A.csv",
   header=TRUE, sep=",", na.strings="NA", dec=".", strip.white=TRUE)

# Turn track into a SpatialPointsDataFrame sby specifying that the "X" and "Y" columns are the coordinates:
coordinates(track) <- c("X", "Y")
class(track)
plot(track)
#Project into utm:
proj4string(track) <- CRS("+init=epsg:32618")
#read shore;ine file
shore <- readShapeSpatial("C:/Users/gemme001/Desktop/R_state_space/STATES_VA_COAST_UTM.shp", delete_null_obj=TRUE)
plot(shore)
proj4string(shore) <- CRS("+init=epsg:32618")
#Add to list the list with the names "map" and "relocs" 
my.homerange.data <- list(map = shore, relocs = track)
#Assign IDs and XY – the IDs work but coordinates don’t work.  I get the following error: Error in `[.data.frame`(x@data, i, j, ..., drop = FALSE) : undefined columns selected
id<-my.homerange.data$relocs$Name
xy<-(my.homerange.data$relocs["X","Y"]
#Create CP – this works
cp <- mcp(my.homerange.data$relocs[,1], percent=95)
class(cp)
plot(cp)
#Create KUD.  This doesn’t work.  I get the following:  Error in xy.coords(x, y, xlabel, ylabel, log) : 'x' is a list, but does not have components 'x' and 'y'
kud <- kernelUD(track[,1], h="href")

4

1 回答 1

0

您现在可能已经解决了您的问题,但以防万一,我终于用我的鸟类数据解决了这个问题,并且遇到了与您相同的问题。我最终在 excel 的数据表的第一列中为每只动物分配了一个 ID,然后重新导入数据。此外,如果您按照 adehabitatHR 教程进行操作,请确保您的 x 和 y 列作为第 2 列和第 3 列并被标记为这样。一旦我以这种格式设置数据,我就能够轻松地将空间数据转换为数据框,然后继续计算 KDE 并获得主范围多边形。

于 2015-02-24T15:44:39.880 回答