[R-sig-Geo] alternative for spixdf2kasc from adehabitat package

Mathieu Basille basille.web at ase-research.org
Mon Jul 8 16:42:46 CEST 2013


Ahah, now I understand that I was slightly out of topic when I answered. 
Sorry about that, I should have read more carefully the initial message!

I'm glad you solved it. This said, it looks like a bug in read.asc from 
SDMTools. Did you try to contact the author? Another solution might be to 
convert the file before reading it in R, to see if it makes any difference. 
For instance, it looks like GDAL is able to correctly handle the file. Did 
you try to convert it to another .asc file using gdal_translate? Maybe it 
would correct your problem from the beginning.

Another, more rational, solution would be that the author(s) of SDMTools 
switch to sp or raster maps! But admittedly, this is not an easy one to 
solve for you :)

Hope this helps, this time...
Mathieu.


Le 07/07/2013 07:28 PM, Andres Merino-Viteri a écrit :
> Thanks Alex and Mathieu for your replies. I am familiar with the new
> packages related to the old adehabitat.
>
> Finally, I solved my problem using rgdal and SDMTools packages as the
> following way:
>
> Veg <- readGDAL("~/Desktop/natur_inter.asc")
> Veg2=raster(Veg)
> blaK <- asc.from.raster(Veg2)
> write.asc(blaK, "~/Desktop/NEW_natur_inter.asc", gz=FALSE)
>
>
>
>
>
> On Sun, Jul 7, 2013 at 10:45 AM, Mathieu Basille <
> basille.web at ase-research.org> wrote:
>
>> Dear Andres,
>>
>> In addition to Alexandre's answers, did you try with the RGDAL package?
>> Something like:
>>
>> veg <- readGDAL("~/Desktop/natur_**inter.asc")
>>
>> This should solve your problem: the asc should be imported as a
>> SpatialPixel object, which can then be used in the new version of
>> adehabitat package, as underlined by Alexandre.
>>
>> Mathieu Basille.
>>
>>
>> Le 07/07/2013 12:46 AM, Alexandre Villers a écrit :
>>
>>   Hello,
>>>
>>> Look at adehabitatHS package (and other related packages adehabitatHR and
>>> adehabitatLT): there are new functions to take advantage of sp class
>>> objects (such as the ones created when reading a raster with rgdal).
>>> Adehabitat is now "deprecated" and you should use these other packages
>>> instead
>>>
>>> HTH
>>>
>>> Alex
>>>
>>>
>>> 2013/7/7 Andres Merino-Viteri <amerinoviteri at gmail.com>
>>>
>>>   Dear list,
>>>>
>>>> Sometimes I have problems opening ASCII files  with read.asc function
>>>> from
>>>> SDMTools package.
>>>>
>>>> The error message is like  the following one:
>>>>
>>>>   Veg=read.asc("~/Desktop/natur_**inter.asc")
>>>>>
>>>> Error in if ((yll[[1]][1] == "yllcenter") | (xll[[1]][1] ==
>>>> "YLLCENTER")) {
>>>> :
>>>>     missing value where TRUE/FALSE needed
>>>> In addition: Warning message:
>>>> In read.asc("~/Desktop/natur_**inter.asc") : NAs introduced by coercion
>>>>
>>>> Looking at different forums I found the following solution to this
>>>> problem:
>>>>
>>>> library("rgdal")
>>>> library("adehabitat")
>>>> B1=readGDAL("~/Desktop/natur_**inter.asc")
>>>> blaK <- spixdf2kasc(B1)
>>>> write.asc(blaK, "~/Desktop/NEW_natur_inter.**asc", gz=FALSE)
>>>>
>>>> It used to solve my problem. The NEW .asc file did not display any error
>>>> message when read with the read.asc function.
>>>>
>>>> However, since I updated to R 2.15.2 GUI 1.53 Leopard build 32-bit
>>>> (6335),
>>>> I can not use adehabitat package anymore, and I have not been able to
>>>> find
>>>> the "spixdf2kasc" function in the new adehabitat family packages. Now, I
>>>> am
>>>> not able to use new .asc files provided to me.
>>>>
>>>> Does anyone have an alternative solution for  the read.asc error? or an
>>>> alternative for using "spixdf2kasc" function?
>>>>
>>>> Any help would be very appreciated. Thanks.
>>>>
>>>> Andres
>>>>
>>>> Additional infor about my R version:
>>>> R version 2.15.2 (2012-10-26) -- "Trick or Treat"
>>>> Copyright (C) 2012 The R Foundation for Statistical Computing
>>>> ISBN 3-900051-07-0
>>>> Platform: i386-apple-darwin9.8.0/i386 (32-bit)
>>>>
>>>> My computer:
>>>> MacBook 2GHz Intel Core 2 Duo
>>>> MAC OS X Version 10.6.8
>>>>
>>>>           [[alternative HTML version deleted]]
>>>>
>>>> ______________________________**_________________
>>>> R-sig-Geo mailing list
>>>> R-sig-Geo at r-project.org
>>>> https://stat.ethz.ch/mailman/**listinfo/r-sig-geo<https://stat.ethz.ch/mailman/listinfo/r-sig-geo>
>>>>
>>>>
>>>
>>>
>>>
>> --
>>
>> ~$ whoami
>> Mathieu Basille, PhD
>>
>> ~$ locate --details
>> University of Florida \\
>> Fort Lauderdale Research and Education Center
>> (+1) 954-577-6314
>> http://ase-research.org/**basille <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
>>
>
>
>
>
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>

-- 

~$ 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



More information about the R-sig-Geo mailing list