[Biomod-commits] ASCII files in BIOMOD

Manuel Spínola mspinola10 at gmail.com
Mon Sep 6 12:18:13 CEST 2010


  Thank you very much Wilfried.
Best,

Manuel


On 05/09/2010 11:37 p.m., Wilfried Thuiller wrote:
> Yes, join will do more or less the same than xyValues.
> I think the xyValues is better as you can also select the type of 
> sampling design (neighbor or bilinear interpolation).
>
> For Maxent asc files, this is easy to load:
>
>
> Compare to what I wrote, it will look like:
>
> mn6190_ann = raster(mn6190_ann.asc)
> cld6190_ann = raster(cld6190_ann.asc)
> mydata = stack(mn6190_ann, cld6190_ann)
>
> myXYvariables = xyValues(CoordXY, mydata)
>
> ## you can remove the stack part with a loop as I wrote below in my 
> first email.
>
> Best
> Wilfried
>
>
>
>
> Le 6 sept. 2010 à 01:06, Manuel Spínola a écrit :
>
>> Thank you very much Wilfried.
>>
>> Yes, I mean ASCII grids.
>>
>> For example, I have 2 files: "tmn6190_ann.asc" and "cld6190_ann.asc" 
>> (layers from MAXENT) but I want to bring them to BIOMOD.
>>
>> I found a function in the adehabitatMA package called "join" that I 
>> think does what I am looking for but it works only for an object of 
>> class "SpatialPixelsDataFrame" (package sp):
>>
>> df <- join(locs, map) # "locs" are animal locations and "map" are 
>> environmental variables.
>>
>> The result is a data frame containing the value of the variables at 
>> the specified locations.
>>
>> Do you think the join function will do the same that you suggested me.
>>
>> Best,
>>
>> Manuel
>>
>>
>> On 05/09/2010 02:34 p.m., Wilfried Thuiller wrote:
>>> Hi Manuel,
>>> What do you mean by ASCII files? Do you mean ASGII grids? (exprt asc 
>>> from raster/grid). I guess your variables were on Arcgis or 
>>> something like that and you exported them on ASCII files?
>>>
>>> If this right, this is rather easy.
>>> Make sure your species data (which I guess is a matrix with X and Y 
>>> coordinates and then columns with presence-absence) and ASCII files 
>>> use the same spatial projection.
>>> Then, load the rgdal and raster package
>>>
>>> then read the ASCII file (one by one) using the raster function of 
>>> the raster package, then build a stack of raster, and then project 
>>> the values of the variables onto the XY values of your sites.
>>> I give you below an example (with arcgis grid layers not ASCII but 
>>> it works the same way).
>>>
>>> Hope it helps
>>>
>>> Wilfried
>>>
>>>
>>> ##### Load my XY data (European data with XY coordinates in column 2 
>>> and 3, and then species.
>>> library(foreign)
>>> AFE_PA_XY <- read.dbf('AFE_PA_XY.dbf')
>>>
>>> ### Create a vector with the names of the variables I want to load 
>>> (here the worldclim data for instance)
>>> bio <- paste(rep('bio', times=19), seq(1:19), sep="_")
>>>
>>> library(raster)
>>> ### Create a loop to load sequentially the raster (the first line in 
>>> the loop) and then project the value of the loaded raster onto the 
>>> XY coordinates of the original file and store directly in the 
>>> dataframe with the name of the loaded raster
>>> You can even add a third line to rm the raster/ASCII layer if it is 
>>> a large dataset, something like: eval(parse(text=paste("rm(",i, ")", 
>>> sep="")))
>>> for(i in bio)
>>> eval(parse(text=paste(i, "<- 
>>> raster('/Volumes/GIS_Data/Global/Climate/Current/Wordclim/10m/bio/", 
>>> i,"')", sep="")))
>>> eval(parse(text=paste("AFE_PA_XY$",i, "xyValues(worldclim, 
>>> AFE_PA_XY[,2:3],method='bilinear')", sep="")))
>>>
>>>
>>>
>>>
>>> Le 5 sept. 2010 à 17:12, Manuel Spínola a écrit :
>>>
>>>> Dear list members,
>>>>
>>>> I know this is a basic question and not completed related to BIOMOD.
>>>> I want to run an analysis using BIOMOD but I would like to know the 
>>>> best way to bring bioclimatic and land use variables from ASCII 
>>>> files to the format that the environmental variables are presented 
>>>> in the BIOMOD manual.
>>>> Thank you very much in advance.
>>>> Best,
>>>>
>>>> Manuel
>>>>
>>>> -- 
>>>> Manuel Spínola, Ph.D.
>>>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>>>> Universidad Nacional
>>>> Apartado 1350-3000
>>>> Heredia
>>>> COSTA RICA
>>>> mspinola at una.ac.cr <mailto:mspinola at una.ac.cr>
>>>> mspinola10 at gmail.com
>>>> Teléfono: (506) 2277-3598
>>>> Fax: (506) 2237-7036
>>>>
>>>> _______________________________________________
>>>> Biomod-commits mailing list
>>>> Biomod-commits at lists.r-forge.r-project.org
>>>> https://lists.r-forge.r-project.org/cgi-bin/mailman/listinfo/biomod-commits
>>>
>>> --------------------------
>>> Dr. Wilfried Thuiller
>>> Laboratoire d'Ecologie Alpine, UMR CNRS 5553
>>> Université Joseph Fourier
>>> BP53, 38041 Grenoble cedex 9, France
>>> tel: +33 (0)4 76 51 44 97
>>> fax: +33 (0)4 76 51 42 79
>>>
>>> Email: wilfried.thuiller at ujf-grenoble.fr 
>>> <mailto:wilfried.thuiller at ujf-grenoble.fr>
>>> Home page: http://www.will.chez-alice.fr 
>>> <http://www.will.chez-alice.fr/>
>>> Website: http://www-leca.ujf-grenoble.fr/equipes/tde.htm
>>>
>>> FP6 European MACIS project: http://www.macis-project.net 
>>> <http://www.macis-project.net/>
>>> FP6 European EcoChange project: http://www.ecochange-project.eu 
>>> <http://www.ecochange-project.eu/>
>>>
>>>
>>>
>>>
>>>
>>
>>
>> -- 
>> Manuel Spínola, Ph.D.
>> Instituto Internacional en Conservación y Manejo de Vida Silvestre
>> Universidad Nacional
>> Apartado 1350-3000
>> Heredia
>> COSTA RICA
>> mspinola at una.ac.cr
>> mspinola10 at gmail.com
>> Teléfono: (506) 2277-3598
>> Fax: (506) 2237-7036
>
> --------------------------
> Dr. Wilfried Thuiller
> Laboratoire d'Ecologie Alpine, UMR CNRS 5553
> Université Joseph Fourier
> BP53, 38041 Grenoble cedex 9, France
> tel: +33 (0)4 76 51 44 97
> fax: +33 (0)4 76 51 42 79
>
> Email: wilfried.thuiller at ujf-grenoble.fr 
> <mailto:wilfried.thuiller at ujf-grenoble.fr>
> Home page: http://www.will.chez-alice.fr <http://www.will.chez-alice.fr/>
> Website: http://www-leca.ujf-grenoble.fr/equipes/tde.htm
>
> FP6 European MACIS project: http://www.macis-project.net 
> <http://www.macis-project.net/>
> FP6 European EcoChange project: http://www.ecochange-project.eu 
> <http://www.ecochange-project.eu/>
>
>
>
>
>


-- 
Manuel Spínola, Ph.D.
Instituto Internacional en Conservación y Manejo de Vida Silvestre
Universidad Nacional
Apartado 1350-3000
Heredia
COSTA RICA
mspinola at una.ac.cr
mspinola10 at gmail.com
Teléfono: (506) 2277-3598
Fax: (506) 2237-7036

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/biomod-commits/attachments/20100906/41de23ed/attachment-0001.htm>


More information about the Biomod-commits mailing list