zonal_stats.pbs 2.3 KB
#!/bin/sh
#PBS -N refl_zonal_stats
#PBS -l select=1:ncpus=20:mem=100gb
#PBS -l walltime=100:00:00


. /work/OT/theia/oso/jordi/OTB/otb_superbuild/otb_superbuild-otb_develop-Release-install/config_otb_tf_py35.sh

TERLAB_DIR=/work/OT/theia/oso/shapes/TERLAB/
DPT=31
TILE=T31TCJ
DEM_DIR=/work/OT/theia/oso/sensorsDatas/MNT_S2_N2/S2__TEST_AUX_REFDE2_${TILE}_0001.DBL.DIR
TERLAB_FILE=RPG_TERLAB_DEP${DPT}_2017
TERLAB_ZIP=$TERLAB_DIR/$TERLAB_FILE.7z
TERLAB_SHP=$TERLAB_DIR/SURFACES-2017-PARCELLES-GRAPHIQUES-CONSTATEES_0${DPT}_20180210.shp
MAASSP_DIR=/work/OT/theia/oso/jordi/maassp_data

#7z x $TERLAB_ZIP -aoa -o$TERLAB_DIR
#otbcli_ZonalStatistics -in ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_MASK.tif -inbv -10000 -inzone.vector.in $TERLAB_SHP -inzone.vector.reproject 1 -out.vector.filename ${MAASSP_DIR}/zonal_stats_mask.shp -ram 30000

# The input image has 720 channels and OGR fails when creating stdev_509, so we can try to split the image in half the bands

CH_LIST1=$(for i in $(seq 1 359);do  echo Channel$i; done)
CH_LIST2=$(for i in $(seq 360 720);do  echo Channel$i; done)

otbcli_ExtractROI -in ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL.tif -out ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL_1.tif int16 -cl ${CH_LIST1} -ram 80000

otbcli_ZonalStatistics -in ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL_1.tif -inbv -10000 -inzone.vector.in $TERLAB_SHP -inzone.vector.reproject 1 -out.vector.filename ${MAASSP_DIR}/zonal_stats_refl_1.shp -ram 80000

otbcli_ExtractROI -in ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL.tif -out ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL_2.tif int16 -cl ${CH_LIST2} -ram 80000

otbcli_ZonalStatistics -in ${MAASSP_DIR}/tiles/T31TCJ/Sentinel2_ST_REFL_2.tif -inbv -10000 -inzone.vector.in $TERLAB_SHP -inzone.vector.reproject 1 -out.vector.filename ${MAASSP_DIR}/zonal_stats_refl_2.shp -ram 80000


#### DEM
# ALTIMG=${DEM_DIR}/S2__TEST_AUX_REFDE2_${TILE}_0001_ALT_R1.TIF
# ASPIMG=${DEM_DIR}/S2__TEST_AUX_REFDE2_${TILE}_0001_ASP_R1.TIF
# SLPIMG=${DEM_DIR}/S2__TEST_AUX_REFDE2_${TILE}_0001_SLP_R1.TIF
# DEMIMG=${MAASSP_DIR}/tiles/T31TCJ/DEM_${TILE}.tif
# otbcli_ConcatenateImages -il ${ALTIMG} ${ASPIMG} ${SLPIMG} -out ${DEMIMG} -ram 30000
# otbcli_ZonalStatistics -in ${DEMIMG} -inbv -10000 -inzone.vector.in $TERLAB_SHP -inzone.vector.reproject 1 -out.vector.filename ${MAASSP_DIR}/zonal_stats_dem.shp -ram 30000