Thanks for the suggestions everyone.  Here's what I tried, and the error
I'm still getting:

> antpen_2 <- readGDAL('shapefiles/antpen500m.asc')
shapefiles/antpen500m.asc has GDAL driver AAIGrid
and has 1555 rows and 1263 columns
> image(antpen_2) #displays fine
> class(antpen_2)
[1] "SpatialGridDataFrame"
attr(,"package")
[1] "sp"
> uu <- kernelkc(t699_b2, h = c(5000,5000,5*3600*24),grid=antpen_2,
+                tcalc= as.POSIXct("2012-01-27"))
Error in as.vector(gr) : no method for coercing this S4 class to a vector
> 


Happy to upload files somewhere if that would be helpful, or provide more
detail on my antpen500m.asc file if that could potentially be the problem.

Thanks all,

Corrie




On 12/10/12 11:40 AM, "Mathieu Basille" <[email protected]> wrote:

>Le 10/12/2012 06:10, Damiano G. Preatoni a écrit :
>> In un messaggio del Wednesday 05 December 2012, Corrie Curtice ha
>>scritto:
>>> Hi folks.
>>>
>>> I have a question about how to supply a grid to the kernelkc method.
>>>In a
>>> previous email
>>> (http://www.mail-archive.com/[email protected]/msg00219.html) Damiano
>>> recommended reading in an ASCII grid file to supply as input to
>>>kernelUD.
>>> At that time, I did this using import.asc from the old adehabitat
>>>package
>>> and I believe it worked fine.  But now I'm working with kernelkc and
>>> running into a problem
>>
>> Well. that behaviour is possible (and in some way, expectable).
>>
>> The "new" Adehabitat* now uses sp and raster classes.
>>
>> This means no 'kasc' objects anymore. You must use sp* classes.
>>
>> This may seem a little pain somewhere ;)  but in fact is a great thing,
>>since
>> now also adehabitat uses standard classes for geodata.
>>
>> The trick should be importing the grid in -say- GeoTIFF format using
>>raster from
>> raster package. The problem is in the conversion into
>>SpatialGridDataFrame.
>
>Two solutions for this:
>
>1) Either use readGDAL to import the raster into R as a SGDF (from almost
>any format);
>2) Or convert a raster to a SGDF using 'sgdf <- as(raster,
>"SpatialGridDataFrame")'.
>
>Mathieu.
>
>
>>>  From the kernelkc help, seems to me I should be able to do the same
>>>thing:
>>>
>>>
>>> grid  a number giving the size of the grid on which the UD should be
>>> estimated. Alternatively, this parameter may be an object of class
>>>asc, or
>>> a list of objects of class asc, with named elements corresponding to
>>>each
>>> level of the burst/id
>>>
>>> I've clipped my area and saved as an ASC file from ArcGIS. I've tried
>>>to
>>> read it in two ways, but get an error both times. One is an asc and
>>>one is
>>> a SpatialGridDataFrame.
>>>
>>> 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]
>>> When I read it in w/ sp read.asciigrid, which produces a
>>> SpatialGridDataFrame I still get an error.
>>>
>>>> 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 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,format="%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: [email protected]
>>> ph: 252-504-7538
>>
>>
>>
>>
>> _______________________________________________
>> AniMov mailing list
>> [email protected]
>> http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov
>>
>
>-- 
>
>~$ whoami
>Mathieu Basille, PhD
>
>~$ locate --details
>University of Florida \\
>Fort Lauderdale Research and Education Center
>(+1) 954-577-6314
>http://ase-research.org/basille
>
>~$ fortune
>« Le tout est de tout dire, et je manque de mots
>Et je manque de temps, et je manque d'audace. »
>  -- Paul Éluard
>_______________________________________________
>AniMov mailing list
>[email protected]
>http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov


_______________________________________________
AniMov mailing list
[email protected]
http://lists.faunalia.it/cgi-bin/mailman/listinfo/animov

Reply via email to