Hi folks. 

I have a question about how to supply a grid to the kernelkc method in
adehabitatHR.  I've clipped my area and saved as an ASC file from ArcGIS.
The kernelkc help says the parameter should be of class asc. I've read it in
as both an asc and a SpatialGridDataFrame, but get an error from kernelkc
regardless of which one I use.

ASC:

library(SDMTools)
> antpen_asc <- read.asc('shapefiles/antpen500m.asc')
> class(antpen_asc)
[1] "asc"
> uu <- kernelkc(t699_b2, h = c(5000,5000,5*3600*24),grid=antpen_asc, tcalc=
as.POSIXct("2012-01-27"))
Error in `gridded<-`(`*tmp*`, value = TRUE) :
  gridded<- only works for SpatialPoints[DataFrame] or
SpatialGrid[DataFrame]
 
SGDF:

> antpen_sgdf <- read.asciigrid('shapefiles/antpen500m.asc', as.image = FALSE,
+                proj4string = CRS('+proj=utm +zone=20 +south
+datum=WGS84'))
> class(antpen_sgdf)
[1] "SpatialGridDataFrame"
attr(,"package")
[1] "sp"
> uu <- kernelkc(t699_b2, h = c(5000,5000,5*3600*24),grid=antpen_sgdf,  tcalc=
as.POSIXct("2012-01-27"))
Error in as.vector(gr) : no method for coercing this S4 class to a vector

The vignette example uses a SpatialPixelsDataFrame for the kernelUD method
but doesn't show an example with kernelkc.  I made an ltraj out of the data
and tried to pass in the supplied map, but I get the same error as when
using a SGDF.  Below is code that should reproduce what I'm seeing.

> data(puechabonsp)
> # regular kernel w/ grid
> kudm <- kernelUD(puechabonsp$relocs[,1], grid=puechabonsp$map)
> 
> # Try product kernel w/ grid. Need to get ltraj
> class(puechabonsp$relocs)
[1] "SpatialPointsDataFrame"
attr(,"package")
[1] "sp"
> puechData<-puechabonsp$relocs@data
> puechData$X <- puechabonsp$relocs@coords[,1]
> puechData$Y <- puechabonsp$relocs@coords[,2]
> puechTraj 
<-as.ltraj(cbind(puechData$X,puechData$Y),as.POSIXct(strptime(puechData$Date,for
mat="%y%m%d")), id=puechData$Name)
> uu <- kernelkc(puechTraj, h = c(1000,1000,72*3600), tcalc=
as.POSIXct("1993-07-20"), grid=puechabonsp$map)
Error in as.vector(gr) : no method for coercing this S4 class to a vector


Here's my session info...

> sessionInfo()
R version 2.13.1 (2011-07-08)
Platform: x86_64-apple-darwin9.8.0/x86_64 (64-bit)

locale:
[1] C/en_US.UTF-8/C/C/C/C

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base

other attached packages:
 [1] SDMTools_1.1-9     adehabitatHR_0.3   adehabitatLT_0.3.4
CircStats_0.2-4    boot_1.3-2         MASS_7.3-13
 [7] adehabitatMA_0.3.2 ade4_1.4-17        tripack_1.3-4      gpclib_1.5-1
sp_0.9-84         

loaded via a namespace (and not attached):
[1] grid_2.13.1     lattice_0.19-30 tools_2.13.1

Am I just too out of date on something(s), or am I completing missing
something obvious in how I should be proceeding?

Thanks for any guidance.

--corrie

---
Corrie Curtice
Research Analyst
Marine Geospatial Ecology Lab
Nicholas School of the Environment, Duke University
http://mgel.env.duke.edu
em: corrie.curt...@duke.edu




        [[alternative HTML version deleted]]

_______________________________________________
R-sig-Geo mailing list
R-sig-Geo@r-project.org
https://stat.ethz.ch/mailman/listinfo/r-sig-geo

Reply via email to