[Biomod-commits] ASCII files in BIOMOD

Wilfried Thuiller wilfried.thuiller at ujf-grenoble.fr
Sun Sep 5 22:34:37 CEST 2010

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


##### Load my XY data (European data with XY coordinates in column 2 and 3, and then species. 
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="_")

### 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
> 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
Home page: 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
FP6 European EcoChange project: http://www.ecochange-project.eu

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

More information about the Biomod-commits mailing list