Dear all,
Thank you a lot for your suggestions!

(In my email forgot to say which packages I was using... I used raster and
SDMTools)

I upgraded R & packages to the newest version and I'm running the code that
Robert suggested. It has been running for almost 4 hours now (there are 8
huge files that need to be cropped).
Yesterday, using the previous R version it took about one hour for R to
send me the no memory error message so I´m hoping that today is working.

In case this works, is there any way to make this faster? Ideally, I would
like to process about 288 layers, sigh!

Thanks heaps again!

Rocio



On Thu, Jul 18, 2013 at 11:14 AM, Robert J. Hijmans <r.hijmans@gmail.com>wrote:

> Rocio,
>
> You should not use functions read.asc and raster.from.asc because they
> read all the values into memory. Also please indicated which packages
> you use. The below should fix the problem:
>
> setwd('G:/future_A2a/2020/bccr_bcm2_0_sres_a2_2020s/')
> library(raster)
> mask<-raster("C:/xalapa/worldclim_pres/bio01.asc")
> files <- list.files(pattern='\\.asc$')
> s <- stack(files)
> x <- crop(s, mask)
>
> And it would indeed good to use a current version of R and its packages.
> Robert
>
>
> On Thu, Jul 18, 2013 at 12:05 AM, Rocio Ponce <r.ponce.reyes@gmail.com>
> wrote:
> > Hi there,
> > I'm a newie in using R to make maps... I used to work with ArcGis but I
> ran
> > out of a valid license...
> >
> > I'm trying to crop the future Worldclim datasets layers which are huge
> > ascii files (of the whole world at 1km resolution, so they are between
> > 3-4GB each)  to the extent of Mexico using the library (raster).
> >
> > I used the following code:
> >
> >>setwd('G:/future_A2a/2020/bccr_bcm2_0_sres_a2_2020s/')
> >>maask<-  read.asc("C:/xalapa/worldclim_pres/bio01.asc",gz=FALSE)
> >>mask<-raster.from.asc(maask,projs=NA)
> >>files <- list.files(pattern='\\.asc$')
> >>s <- stack(files)
> >> crop(s, mask)
> > Error: cannot allocate vector of size 253.2 Mb
> >
> >
> > I'm using R.2.14.1 on a computer running on Windows XP
> > Any help that you could provide me would be greatly appreciated,
> >
> > Cheers,
> > Rocio
> >
> > --
> > Dr. Rocio Ponce-Reyes
> >
> > http://rocioponcereyes.wordpress.com/
> >
> > (disculpe la falta de acentos en este correo electronico)
> >
> >         [[alternative HTML version deleted]]
> >
> > _______________________________________________
> > R-sig-Geo mailing list
> > R-sig-Geo@r-project.org
> > https://stat.ethz.ch/mailman/listinfo/r-sig-geo
>



-- 
Dr. Rocio Ponce-Reyes

http://rocioponcereyes.wordpress.com/

(disculpe la falta de acentos en este correo electronico)

	[[alternative HTML version deleted]]

