adehabitatHR KD ID and XY assignement

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

adehabitatHR KD ID and XY assignement

Gwen G. Lockhart

Hello Everyone...

I am fairly new to R. I would like to use the adehabitatHR package to create kernel density and isopleths from my sea turtle GPS data. I�m running into some issues�

Basically I am having trouble assigning IDs and XY fields within R to create KDs and MCPs.

Thank you in advance for any help!



Gwen Lockhart
GIS Research Specialist
Virginia Aquarium and Marine Science Center Foundation
Division of Research and Conservation
[hidden email]<mailto:[hidden email]>
Desk: 757-385-6486
Cell: 757-748-6757


#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)

#####THIS IS WHERE I AM RUNNING INTO ISSUES#####
#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")

        [[alternative HTML version deleted]]


______________________________________________
[hidden email] mailing list -- To UNSUBSCRIBE and more, see
https://stat.ethz.ch/mailman/listinfo/r-help
PLEASE do read the posting guide http://www.R-project.org/posting-guide.html
and provide commented, minimal, self-contained, reproducible code.