foreach - Parallel processing MODIS images in R -


i have downloaded vegetation data modis africa , trying yo create mosaics images , save them geo tif. have no problem doing until try run in parallels on macpro 6cores, 12 threads. code runs uses 1% of cores availability , takes ever complete processes.

i need help, have more 70gb of modis granules need convert mosaic , if don't use computer power got in lab take ever.

here code part of parallel processing:

there 2 parts run in parallel, 1. select ndvi; 2. create mosaics, project them , save them .tif.

# register cluster 10 cores  registerdoparallel(cores=11) micluster<-makecluster(11) registerdoparallel(micluster) library(domc) registerdomc(11)  # 1. # select ndvi each africa granule , put in sdslist sdslist <- foreach(k = 1:length(dategranules), .packages=c("raster", "gdalutils","foreach"))%dopar%{   for(j in 1:1:length(dategranules)){     return(sapply(x=dategranules[[j]], fun=function(x){get_subdatasets(x)[1]}))   } }  2. # generate mosaic africa ndvi aoutput foreach(j = 1:length(sdslist), .packages=c("raster", "gdalutils", "foreach"))%dopar%{     gdalwarp(srcfile=sdslist[[j]], t_srs="+proj=longlat +datum=wgs84   +no_defs",       dstfile=file.path(dest, names[j])) }   

why use r @ all, when can in 2 lines, shell, multi threading , faster using gdal utilities?

if understand question , code correctly want extract ndvi subdataset from, presumably mod13q1, hdf5 containers, reproject lat/lon, change filetype geotiff , mosaic granules covering africa 1 large mosaic.

  1. build virtual raster table containing ndvi subdatasets.

gdalbuildvrt -sd 1 ndvi.vrt mod13q1.*.hdf

note use of -sd 1 takes first subdataset every hdf container.

  1. reproject , change format.

gdalwarp gdalwarp -t_srs "+proj=longlat +datum=wgs84 +no_defs" -multi ndvi.vrt ndvi-mosaic.tif

step 1 takes virtually no time since creates metadata file containing information hierarchy of hdf files , no actual processing done. if granules adjacent, e.g. h15v05, h15v04, h14v05,..., mosaiced correctly geolocation.

step 2 actual reprojection , file format change. tested on core2duo (3ghz) , reprojection of 20 modis granules took 1.5 minutes. without multi-threading should lot faster in r.


Comments

Popular posts from this blog

Fail to load namespace Spring Security http://www.springframework.org/security/tags -

sql - MySQL query optimization using coalesce -

unity3d - Unity local avoidance in user created world -