[R-sig-Geo] parallelize projectRaster()

Jonathan Greenberg jgrn at illinois.edu
Wed Jun 18 17:03:25 CEST 2014


Yerguner:

You might want to consider using gdalUtils
(http://cran.r-project.org/web/packages/gdalUtils/index.html) --
reprojecting via gdal warp is really fast and you can even get it
cranking on multiple processors.

--j

On Wed, Jun 18, 2014 at 12:24 AM, Yerguner <yasebaytok at gmail.com> wrote:
> 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.
>
> _______________________________________________
> R-sig-Geo mailing list
> R-sig-Geo at r-project.org
> https://stat.ethz.ch/mailman/listinfo/r-sig-geo



-- 
Jonathan A. Greenberg, PhD
Assistant Professor
Global Environmental Analysis and Remote Sensing (GEARS) Laboratory
Department of Geography and Geographic Information Science
University of Illinois at Urbana-Champaign
259 Computing Applications Building, MC-150
605 East Springfield Avenue
Champaign, IL  61820-6371
Phone: 217-300-1924
http://www.geog.illinois.edu/~jgrn/
AIM: jgrn307, MSN: jgrn307 at hotmail.com, Gchat: jgrn307, Skype: jgrn3007



More information about the R-sig-Geo mailing list