[R-sig-Geo] parallelize projectRaster()

Yerguner yasebaytok at gmail.com
Wed Jun 18 07:24:47 CEST 2014


Hi All,

Below sample script do the job with a small multi-layered netcdf file (200M)
but it takes ~8 hrs to complete. I need to do the same process with a large
netcdf file(5.5 GB -that I cut this sample file from). I am wondering if
there is way to parallelize this process using beginCluster()-counting on
the build-in capacity of projectRaster()- OR using doParallel().

Thanks,
Yasemin

library(raster)
library(ncdf4)
library(rgdal)
rasterOptions(tmpdir=“/my_tmp_path/“)
ifile <- "cold2002_s1.nc"
colds1 <- brick(ifile)

> NAvalue(colds1)
[1] -9999
colds1[colds1 == -9999] <- NA 
> NAvalue(colds1)
[1] -1.7e+308

newproj <- "+proj=laea +lat_0=45 +lon_0=-100 +x_0=0 +y_0=0 +a=6370997
+b=6370997 +units=m +no_defs"
prjs1<- projectExtent(colds1, newproj) 
res(prjs1) <- c(231.6564, 231.6563)
prjs1 <- projectRaster(colds1, prjs1, method='ngb')
ifile2 <- "/mod2002.tif"
mod02 <- raster(ifile2)
submod02 <- crop(mod02,prj1)
bb <- extent(581811.7, 791924.1, 347931.5, 454493.4)
extent(submod02) <- bb
submod02f <- setExtent(submod02, bb, keepres=FALSE)
stackSelect(prj1,submod02f,filename="modcold02.tif",options="INTERLEAVE=BAND")



--
View this message in context: http://r-sig-geo.2731867.n2.nabble.com/parallelize-projectRaster-tp7586598.html
Sent from the R-sig-geo mailing list archive at Nabble.com.



More information about the R-sig-Geo mailing list