1

I have estimated my kernels using kernelUD from the adehabitatHS package which produces information from multiple animals as a class estUDm. I am trying to write out from R to get into ArcGIS the raster from each of the animals.

myrkde <- kernelUD(mytrial[,1], h="href", same4all=T, grid=200, extent = 0.2)

So, I turn the kernelUD into a spixdf

b <- estUDm2spixdf(myrkde)

Only, I want a raster of each animal so I thought to stack the SPIXDF and then write each out.

rastyrday <- stack(b)
writeRaster(rastyrday, filename=paste("MooseYrHR", names(b)) , format="raster", bylayer=T, overwrite=T)

The problem is when I write out the raster, ArcGIS says Invalid raster dataset. Failed to create raster layer. So I change the format to "img" file...OR I change format as "ascii". Both of these produce something that ArcGIS can read/visualize - however, the next problem is that the values are all sooooo small that ArcGIS only registers each value as 0. When I use ArcGIS to look at the pixel values it tells me the value is 0.000000, though the max value is often x*10^-7. Basically, its cutting off after 6 significant digits and my values are 7 to 9.

If I writeRaster and format to ascii, the output indicates min and max values are all NA

writeRaster(rastyrday, filename=paste("atesttest", names(b)) , format="ascii", type = "Float32", bylayer=T, overwrite=T)
class       : RasterStack 
dimensions  : 200, 138, 27600, 29  (nrow, ncol, ncell, nlayers)
resolution  : 159.6563, 159.6563  (x, y)
extent      : 1470049, 1492082, 6602809, 6634741  (xmin, xmax, ymin, ymax)
coord. ref. : NA 
names       : atesttest_Aug2010_F07002_1, atesttest_Aug2010_F07002_2, atesttest_Aug2010_F07002_3, atesttest_Aug2010_F07002_4, atesttest_Aug2010_F07002_5, atesttest_Aug2010_F07002_6, atesttest_Aug2010_F07002_7, atesttest_Aug2010_F07002_8, atesttest_Aug2010_F07002_9, atesttest//_F07002_10, atesttest//_F07002_11, atesttest//_F07002_12, atesttest//_F07002_13, atesttest//_F07002_14, atesttest//_F07002_15, ... 
min values  :                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                    NA,                    NA,                    NA,                    NA,                    NA,                    NA, ... 
max values  :                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                         NA,                    NA,                    NA,                    NA,                    NA,                    NA,                    NA,

If I writeRaster as "raster" or "HFA" at least the min/max values are indicated - but still I get the failed to create raster when using the raster output type or 0's when converting to the image.

writeRaster(rastyrday, filename=paste("atesttest", names(b)) , format="HFA", type = "Float32", bylayer=T, overwrite=T)
class       : RasterStack 
dimensions  : 200, 138, 27600, 29  (nrow, ncol, ncell, nlayers)
resolution  : 159.6563, 159.6563  (x, y)
extent      : 1470049, 1492082, 6602809, 6634741  (xmin, xmax, ymin, ymax)
coord. ref. : NA 
names       : atesttest_Aug2010_F07002_1, atesttest_Aug2010_F07002_2, atesttest_Aug2010_F07002_3, atesttest_Aug2010_F07002_4, atesttest_Aug2010_F07002_5, atesttest_Aug2010_F07002_6, atesttest_Aug2010_F07002_7, atesttest_Aug2010_F07002_8, atesttest_Aug2010_F07002_9, atesttest//_F07002_10, atesttest//_F07002_11, atesttest//_F07002_12, atesttest//_F07002_13, atesttest//_F07002_14, atesttest//_F07002_15, ... 
min values  :                          0,                          0,                          0,                          0,                          0,                          0,                          0,                          0,                          0,                     0,                     0,                     0,                     0,                     0,                     0, ... 
max values  :               2.351000e-07,               4.006146e-07,               6.310832e-07,               3.072779e-07,               2.306967e-07,               2.216463e-07,               2.233004e-07,               2.483713e-07,               4.006146e-07,          2.593051e-07,          1.439714e-07,          1.587329e-07,          2.105937e-07,          2.340155e-07,          2.380073e-07, ...

if I convert the estUDm2spixdf to a raster before stacking -

b <-raster(estUDm2spixdf(myrkde)) 

It only writes the very first animal - all other animals "layers" are lost. And I still end up with the same problem of the outputs either being invalid or 0's for pixel values.

How do I get each animal's UD out of adehabitatHS? Or how do I get the ascii/img files to have significant digits small enough to recognize that there are values in the raster layer? or how do I get the raster file output to be recognized in ArcGIS?

I have posted this question to the ade4 listserve, but because writewRaster is not part of their "thing" I thought I would try here too. As some of these commands come from the sp package and the raster package.

Im using R 3.0 and ArcGIS 10.2

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.