[R-sig-eco] from estUD to SpatialGridDataFrame in adehabitatMA
Sebastian P. Luque
spluque at gmail.com
Fri Mar 23 17:00:54 CET 2012
On Fri, 23 Mar 2012 16:37:42 +0100,
Clement Calenge <clement.calenge-65xOkShCj2YVnxGAtMSvJw at public.gmane.org> wrote:
> Hi, Please consider this example:
>> ## Load the data data(puechabonsp) loc <- puechabonsp$relocs ##
>> Estimation of UD for the four animals (ud <- kernelUD(loc[,1]))
> ********** Utilization distribution of several Animals ************
> Type: probability density Smoothing parameter estimated with a href
> smoothing parameter This object is a list with one component per
> animal. Each component is an object of class estUD See estUD-class
> for more information
> As indicated, the result is a list with one estUD per animal. See for
> example the first element:
>> ud[[1]]
> ********** Utilization distribution of an Animal ************
> Type: probability density Smoothing parameter estimated with a href
> parameter This object inherits from the class SpatialPixelsDataFrame.
> See estUD-class for more information
> As indicated, this object already inherits the class
> SpatialPixelsDataFrame. So that all functions requiring a
> SpatialPixelsDataFrame can take this object as argument. No need for
> coercion:
>> inherits(ud[[1]], "SpatialPixelsDataFrame")
> [1] TRUE
Thanks Clement, it's great to have all adehabitat objects inheriting
from sp classes.
Ultimately, I need to export the objects to Arc/Info ASCII Grid format,
which can be achieved by using the Gdal AAIGrid driver, via the rgdal
package. This fails in my system (using your ud object above):
---<--------------------cut here---------------start------------------->---
library(rgdal)
locs.gtiff <- create2GDAL(ud[[1]],
drivername="GTiff")
locs.aaigrid <- copyDataset(locs.gtiff,
driver="AAIGrid")
saveDataset(locs.aaigrid, "~/tmp/test.asc")
---<--------------------cut here---------------end--------------------->---
Returns this:
Error in .local(.Object, ...) : Dataset copy failed
---<--------------------cut here---------------start------------------->---
R> sessionInfo()
R version 2.15.0 beta (2012-03-16 r58769)
Platform: x86_64-pc-linux-gnu (64-bit)
locale:
[1] LC_CTYPE=en_CA.UTF-8 LC_NUMERIC=C LC_TIME=en_CA.UTF-8
[4] LC_COLLATE=en_CA.UTF-8 LC_MONETARY=en_CA.UTF-8 LC_MESSAGES=en_CA.UTF-8
[7] LC_PAPER=C LC_NAME=C LC_ADDRESS=C
[10] LC_TELEPHONE=C LC_MEASUREMENT=en_CA.UTF-8 LC_IDENTIFICATION=C
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] rgdal_0.7-8 adehabitatHR_0.3.4 adehabitatLT_0.3.4 CircStats_0.2-4
[5] boot_1.3-4 MASS_7.3-17 adehabitatMA_0.3.3 ade4_1.4-17
[9] rgeos_0.2-5 stringr_0.6 deldir_0.0-16 sp_0.9-97
[13] latticeExtra_0.6-19 RColorBrewer_1.0-5 lattice_0.20-6
loaded via a namespace (and not attached):
[1] grid_2.15.0 plyr_1.7.1 tools_2.15.0
---<--------------------cut here---------------end--------------------->---
--
Seb
More information about the R-sig-ecology
mailing list