2015-02-11 21 views
0

我對R相當新。我想使用adehabitatHR軟件包從我的海龜GPS數據中創建內核密度和等值線。我遇到了一些問題...adehabitatHR KD ID和XY分配

基本上我在指定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`([email protected], 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")

回答

0

你現在可能想通了你的問題,但爲了以防萬一,我剛剛終於想通了這一點與我的鳥的數據和有同樣的問題,你。最後,我在Excel數據表的第一列中爲每隻動物分配一個ID,然後重新導入數據。另外,如果您要跟隨adehabitatHR教程一起閱讀,請確保您的x和y列作爲第二列和第三列並標記爲這樣。一旦以這種格式設置我的數據,我就可以輕鬆地將空間數據轉換爲數據框,並繼續計算KDE並獲取家庭範圍多邊形。