Page MenuHomec4science

project_GHI.sh
No OneTemporary

File Metadata

Created
Sat, Apr 26, 12:46

project_GHI.sh

#!/bin/bash
##== User input
LAYER_DEPTH=$1
LAYER_NAME=$2
PROJ_METHOD=$3 # one of nearest, bilinear, bicubic
OUTFILE=$4
##== Constants
LOC=WSG84
MAP=PERMANENT
NULL_VAL=-9999
##== MAIN SCRIPT
# print inputs:
echo Layer information: depth = $1, name = $2
echo Interpolation method for projection: $3
echo Output file: $4
# project all layers into current coordinate system using given method
for ID in `seq 1 $LAYER_DEPTH`; do
echo $ID
r.proj location=$LOC mapset=$MAP input=$LAYER_NAME\.$ID method=$PROJ_METHOD --overwrite
done
# create sequence of layers in ascending order
LAYER_SEQ=$LAYER_NAME\.1
for ID in `seq 2 $LAYER_DEPTH`; do
LAYER_SEQ=$LAYER_SEQ\,$LAYER_NAME\.$ID
done
echo $LAYER_SEQ
# extend region in 3D for current length of input
g.region t=$LAYER_DEPTH b=0 -p3
# convert layers to 3D raster
r.to.rast3 input=$LAYER_SEQ output=$LAYER_NAME --overwrite
# save 3D raster in OUTFILE
r3.out.netcdf -p input=$LAYER_NAME output=$OUTFILE null=$NULL_VAL --overwrite
echo DONE

Event Timeline