Parallel Raster Extraction

This is my job submission script for the raster extraction.

#!/bin/bash -l
#PBS -l walltime=48:00:00,nodes=1:ppn=24,mem=61gb
#PBS -m abe
#PBS -M myaddress@email.com
module load gdal/2.0.1
module load proj
module load R
module load ompi
module load udunits
module load geos

export OMP_NUM_THREADS=1
mpirun -v -hostfile $PBS_NODEFILE -np 1 R --slave CMD BATCH ./extract.R /dev/stdout

This is the R script.

library(raster)
library(rgdal)
library(Rmpi)
library(sf)
all <- stack("all.tif")
forest <- st_read(dsn="./forest",layer="forest_simple")

beginCluster(n=23,type="MPI")
raster_cells <- extract(all,forest)
endCluster()

save(raster_cells,file="raster_vals.RData")

 

Leave a Reply

Your email address will not be published. Required fields are marked *