[Biomod-commits] Projection.raster error?

jason b mackenzie jasonbmackenzie at gmail.com
Fri Feb 10 09:21:55 CET 2012


Hi Wilfried

I got the list.files( ) code for stacking off an earlier post on this list. typically i would use something more like below, but if i compare stacks produced by both approaches, i still get the same maps, vectors or values from functions, such as plots( ), layerNames( ) and setMinMax ( ). the dim ( ) of individual RasterLayers and the RasterStacks appear to be fine? 

Any other suggestions what might be wrong with formatting?

I know you're busy, so thanks for the response.

Cheers, 
Jason



library(raster)
setwd("/Users/jmackenzie/Documents/R/R_data/SD/raster/current/")
bio_1      <- raster("bio_1.asc")
bio_3      <- raster("bio_3.asc")
bio_4      <- raster("bio_4.asc")
bio_5      <- raster("bio_5.asc")
bio_12     <- raster("bio_12.asc")
bio_14     <- raster("bio_14.asc")
bio_15     <- raster("bio_15.asc")
soil_aws5k <- raster("soil_aws5k.asc")
current    <- stack(bio_1, bio_3, bio_4, bio_5, bio_12, bio_14, bio_15, soil_aws5k)




On Feb 10, 2012, at 6:02 PM, Wilfried Thuiller wrote:

> Dear Jason,
> 
> This is indeed surprising. 
> 
> I am bit surprised with the following code 
> 
> files <- list.files("~/Documents/R/R_data/SD/raster/current", pattern='asc', full.names=T)
> CurrentStack <- stack(files[c(1,13,14,15,4,6,7,20)])
> 
> Are you sure it works fine? 
> Try to make a plot of CurrentStack and print the summary of the rasters. I am surprised you manage to stack these files whereas you do not give the pass to stack. 
> 
> In any case, it seems that CurrentStack data are not in the good format. 
> 
> Best
> Wilfried
> 
> 
> 
> Le 8 févr. 2012 à 02:03, jason b mackenzie a écrit :
> 
>> 
>> All
>> 
>> 
>> I am getting an error (below) using the Projection.raster function. 
>> 
>> Error in model.frame.default(Terms, newdata, na.action = na.action, xlev = object$xlevels) : 
>>   invalid type (list) for variable 'DataF'
>> In addition: Warning message:
>> 'newdata' had 5711 rows but variable(s) found have 1131 rows
>> 
>> 
>> 
>> I thought part of the problem might relate to differences in the naming of my explanatory variables, but they appear to be the same in both my presence-absence site data (='SP.ENV') and my RasterStack (='CurrentStack').
>> 
>> > colnames(SP.ENV[,4:11])
>> [1] "bio_1"      "bio_3"      "bio_4"      "bio_5"      "bio_12"     "bio_14"     "bio_15"     "soil_aws"
>> > layerNames(CurrentStack)
>> [1] "bio_1"      "bio_3"      "bio_4"      "bio_5"      "bio_12"     "bio_14"     "bio_15"     "soil_aws"
>> 
>> 
>> 
>> Also, the row flags noted in the warning message don't correspond with dimensions of either dataset?
>> 
>> > dim(SP.ENV)
>> [1] 1742   75
>> > dim(CurrentStack)
>> [1] 232 238   8
>> 
>> 
>> 
>> Any suggestions? FYI, I am running the latest versions of R (2.14.1) and BIOMOD (1.1.7) and my calls are pasted below.
>> 
>> 
>> 
>> Cheers, 
>> Jason
>> 
>> 
>> -- 
>> 
>> Jason MacKenzie, PhD
>> Senior Conservation Fellow
>> The Nature Conservancy
>> 201 Mission Street, 4th Floor
>> San Francisco, CA 94105
>> jmackenzie at tnc.org
>> jasonbmackenzie        [skype]
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> 
>> library(raster)
>> library(BIOMOD)
>> 
>> setwd("~/Documents/R/R_data/SD/veg4")
>> SP.ENV <- read.table("SPENV_veg4.txt",  h=T, sep="\t")
>> COORxy <- read.table("CoorXY_veg4.txt", h=T, sep="\t")
>> 
>> Initial.State(Response=SP.ENV[,12:13], Explanatory=SP.ENV[,4:11], IndependentResponse=NULL, IndependentExplanatory=NULL)
>> 					
>> Models(GLM=F, TypeGLM="quad", Test="AIC", GAM=T, Spline=4, GBM=T, No.trees=3000, CTA=T, CV.tree=50, ANN=T, CV.ann=3, SRE=T, quant=0.025, FDA=T, MARS=T, RF=T, NbRunEval=3, DataSplit=70, Yweights=NULL, Roc=T, Optimized.Threshold.Roc=T, Kappa=T, TSS=T, KeepPredIndependent=F, VarImport=5, NbRepPA=2, strategy="sre", nb.absences=1000)
>> 
>> CurrentPred(GLM=F, GAM=T, GBM=T, CTA=T, ANN=T, SRE=T, FDA=T, MARS=T, RF=T, BinRoc=T,  BinKappa=T,  BinTSS=T, FiltRoc=T, FiltKappa=T, FiltTSS=T) 
>> 								
>> PredictionBestModel(method='all', Bin.trans=T, Filt.trans=T)	
>> 		
>> files <- list.files("~/Documents/R/R_data/SD/raster/current", pattern='asc', full.names=T)
>> CurrentStack <- stack(files[c(1,13,14,15,4,6,7,20)])
>> 
>> Projection.raster(RasterProj = CurrentStack, Proj.name='CurrentRaster', GLM=F, GAM=T, GBM=T, CTA=T, ANN=T, SRE=T, quant=0.025, FDA=T, MARS=T, RF=T, BinRoc=T, BinKappa=T, BinTSS=T, FiltRoc=T, FiltKappa=T, FiltTSS=T, repetition.model=T, stack.out=T, compress="gzip")
>> 
>> 
>> 
>> _______________________________________________
>> 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
> Personal website: http://www.will.chez-alice.fr
> Team website: http://www-leca.ujf-grenoble.fr/equipes/emabio.htm
> 
> ERC Starting Grant TEEMBIO project: http://www.will.chez-alice.fr/Research.html
> FP6 European EcoChange project: http://www.ecochange-project.eu
> 
> 
> 
> 
> 
> 
> 


--

jason b mackenzie
80 banambila street
aranda, act 2614

0447 002 629  [mobile]
jasonbmackenzie    [skype]




-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.r-forge.r-project.org/pipermail/biomod-commits/attachments/20120210/aca76d06/attachment-0001.html>


More information about the Biomod-commits mailing list