-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathlaunch_align_diff.sh
executable file
·99 lines (83 loc) · 3.16 KB
/
launch_align_diff.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
#!/usr/bin/bash
# help
Help()
{
# Display Help
echo "Syntax: launch_align.sh -n dir_list [-h|v|f]"
echo "options:"
echo "n input file: list of directories"
echo "h Print this Help."
echo "v Verbose mode."
echo "f Force mode: overwirte all files and directories."
echo "Carefull: asp_parameters.txt file must be in this directory"
echo
}
FORCE='FALSE'
VERBOSE='FALSE'
# Get the options
while getopts ":hvfn:" option; do
case $option in
h) # display Help
Help
exit;;
v) # verbose mode
VERBOSE='TRUE';;
f) # force mode
FORCE='TRUE';;
n) PAIRS=$OPTARG;;
\?) echo "Error: "$OPTARG "is an invalid option"
exit;;
esac
done
# Initial checkings
if [ -z $PAIRS ]; then { Help; exit 1; } fi
if [ ! -f "asp_parameters.txt" ]; then
echo "missing parameter file: asp_parameters.txt"
echo ; exit
fi
module load asp
. ./asp_parameters.txt
# set input DEM
DEM=$DEM_FILE
DEM_UTM_FILE=$PWD"/"$(basename $DEM .tif)"_utm.tif"
# set home directory
ROOT=$PWD
cat < $PAIRS | while true
do
read ligne
echo
echo "Processing...."
echo $ligne
if [ "$ligne" = "" ]; then break; fi
set -- $ligne ; DIR1=$1 ; DIR2=$2 ;
cd $ROOT
# set output dir
OUTPUT_DIR=$ROOT/diff-$DIR1-$DIR2
if [ $FORCE = 'TRUE' ]; then
rm -rf $OUTPUT_DIR
fi
if [[ ! -d $OUTPUT_DIR ]]; then
mkdir $OUTPUT_DIR
fi
if [[ ! -f $OUTPUT_DIR/run-trans_reference-DEM.tif ]]; then
pc_align --max-displacement 100 --save-transformed-source-points --save-inv-transformed-reference-points $ROOT/$DIR1/demPleiades/dem-PC.tif $ROOT/$DIR2/demPleiades/dem-PC.tif -o $OUTPUT_DIR/run
cd $OUTPUT_DIR
point2dem --t_srs EPSG:$UTM --tr $RES run-trans_reference.tif --median-filter-params $MED_F_PAR --dem-hole-fill-len $DEM_HOLE_F_L --erode-length $ERODE_L --nodata-value $NO_DATA_DEM --tif-compress $TIF_COMPR --max-valid-triangulation-error $MAX_V_TRIANG_ERR --remove-outliers-param $RM_OUTL_PARA
fi
if [[ ! -f $OUTPUT_DIR/diff-dsm.tif ]]; then
# clipping the ref DEM with the another DEM and compute diff
echo raster_diff.py --infile1=$OUTPUT_DIR/run-trans_reference-DEM.tif --infile2=$ROOT/$DIR2/demPleiades/dem-DEM.tif --outfile=diff-dsm.tif
raster_diff.py --infile1=$OUTPUT_DIR/run-trans_reference-DEM.tif --infile2=$ROOT/$DIR2/demPleiades/dem-DEM.tif --outfile=$OUTPUT_DIR/diff-dsm.tif
fi
if [[ ! -f $OUTPUT_DIR/dsm_clipped.tif ]]; then
# compute slope on reference DEM
echo raster_diff.py --infile1=$OUTPUT_DIR/run-trans_reference-DEM.tif --infile2=$ROOT/$DIR2/demPleiades/dem-DEM.tif --outfile=dsm1_clipped.tif
raster_diff.py --infile1=$OUTPUT_DIR/run-trans_reference-DEM.tif --infile2=$ROOT/$DIR2/demPleiades/dem-DEM.tif --intersec=yes --outfile=$OUTPUT_DIR/dsm_clipped.tif
mv intersection1.tif $OUTPUT_DIR/.
echo gdaldem slope $OUTPUT_DIR/dsm_clipped.tif $OUTPUT_DIR/dsm_clipped_slope.tif -of GTiff -b 1 -s 1.0
gdaldem slope $OUTPUT_DIR/dsm_clipped.tif $OUTPUT_DIR/dsm_clipped_slope.tif -of GTiff -b 1 -s 1.0
fi
# compute error estimation
echo dem_error_estimation.py --diff=$OUTPUT_DIR/diff-dsm.tif --slope=$OUTPUT_DIR/dsm_clipped_slope.tif
dem_error_estimation.py --diff=$OUTPUT_DIR/diff-dsm.tif --slope=$OUTPUT_DIR/dsm_clipped_slope.tif
done