[R-sig-Geo] working with large ascii files in R

Robert J. Hijmans r.hijmans at gmail.com
Thu Jul 18 18:14:41 CEST 2013


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 at 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 at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



More information about the R-sig-Geo mailing list