1 |
1 |
|
|
2 |
# perform a merging action for the /mnt/data2/dem_variables/GMTED2010/altitude/class_mi and /mnt/data2/dem_variables/GMTED2010/altitude/class_mx
|
|
3 |
# create in avery clever way missing tiles. The missing tiles were appear if all the pixel where above or below a treshold, therfore all 100% or 0%
|
2 |
4 |
|
3 |
|
# for dir in `seq -500 100 8600` ; do echo $dir mi ; done | xargs -n 2 -P 1 bash /mnt/data2/dem_variables/GMTED2010/scripts/sc3_class_treshold_density_merge.sh
|
|
5 |
# for dir in `seq -500 100 8600` ; do echo $dir mi ; done | xargs -n 2 -P 20 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
|
|
6 |
|
|
7 |
# for dir in `seq -500 100 8700` ; do echo $dir mx ; done | xargs -n 2 -P 20 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
|
4 |
8 |
|
5 |
9 |
DIR=$1
|
6 |
10 |
mm=$2
|
7 |
|
INDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_mi/class${DIR}
|
8 |
|
INDIR_C=/mnt/data2/dem_variables/GMTED2010/altitude/class_mi/class
|
|
11 |
INDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class${DIR}
|
|
12 |
INDIR_C=/mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class
|
9 |
13 |
OUTDIR=/mnt/data2/dem_variables/GMTED2010/altitude/percent_class_${mm}
|
10 |
14 |
|
11 |
|
rm $OUTDIR/file_processed_sc3.txt # the file has ben processed by the script sc1_dem_treshold_percent.sh
|
|
15 |
rm -f $OUTDIR/file_processed_sc3.txt # the file has ben processed by the script sc1_dem_treshold_percent.sh
|
12 |
16 |
|
13 |
17 |
for file in `ls $INDIR_C/*.tif` ; do
|
14 |
18 |
tile=`basename $file _class.tif`
|
... | ... | |
18 |
22 |
echo $tile"_C"$DIR"Perc.tif" >> $OUTDIR/file_processed_sc3.txt # usefull to list file processed by script sc1, in case of delatio use this.
|
19 |
23 |
else
|
20 |
24 |
|
21 |
|
gdalinfo -mm /mnt/data2/dem_variables/GMTED2010/altitude/class_mi/class/$tile"_class.tif" | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > /tmp/ramdisk/$filename"_min_max_"$mm.txt
|
|
25 |
gdalinfo -mm /mnt/data2/dem_variables/GMTED2010/altitude/class_${mm}/class/$tile"_class.tif" | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt
|
22 |
26 |
|
23 |
|
min=`awk '{ print $1}' /tmp/ramdisk/${filename}_min_max_${mm}.txt`
|
24 |
|
max=`awk '{ print $2}' /tmp/ramdisk/${filename}_min_max_${mm}.txt`
|
25 |
|
rm -f /tmp/ramdisk/${filename}_min_max_${mm}.txt
|
|
27 |
min=`awk '{ print $1}' /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt`
|
|
28 |
max=`awk '{ print $2}' /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt`
|
|
29 |
rm -f /tmp/ramdisk/${tile}_class${DIR}_min_max_${mm}.txt
|
26 |
30 |
|
27 |
31 |
echo $min and $max compare to $DIR
|
28 |
32 |
|
29 |
33 |
if [ $max -lt $DIR ] ; then
|
30 |
34 |
echo building the $INDIR/$tile"_C"$DIR"Perc.tif" with 0 value
|
31 |
|
pkgetmask -min 100 -max 101 -t 0 -ot Byte -i $INDIR_C/$tile"_class.tif" -co COMPRESS=LZW -o $INDIR/$tile"_C"$DIR"Perc.tif"
|
32 |
|
# gdalwarp -overwrite -tr 0.00833333333333 -0.00833333333333 -co COMPRESS=LZW -ot Byte $INDIR/$tile"_C"$DIR"Perc_tmp.tif" $INDIR/$tile"_C"$DIR"Perc.tif"
|
33 |
|
# rm $INDIR/$tile"_C"$DIR"Perc_tmp.tif"
|
|
35 |
pkgetmask -min 10000 -max 10001 -t 0 -ot Byte -i $INDIR_C/$tile"_class.tif" -co COMPRESS=LZW -o $INDIR/$tile"_C"$DIR"Perc.tif"
|
|
36 |
|
34 |
37 |
fi
|
35 |
38 |
|
36 |
39 |
if [ $min -gt $DIR ] ; then
|
37 |
40 |
echo building the $INDIR/$tile"_C"$DIR"Perc.tif" with 100 value
|
38 |
|
pkgetmask -min 100 -max 101 -t 0 -f 100 -ot Byte -co COMPRESS=LZW -i $INDIR_C/$tile"_class.tif" -o $INDIR/$tile"_C"$DIR"Perc.tif"
|
39 |
|
# gdalwarp -overwrite -tr 0.00833333333333 -0.00833333333333 -co COMPRESS=LZW -ot Byte $INDIR/$tile"_C"$DIR"Perc_tmp.tif" $INDIR/$tile"_C"$DIR"Perc.tif"
|
40 |
|
# rm $INDIR/$tile"_C"$DIR"Perc_tmp.tif"
|
|
41 |
pkgetmask -min 10000 -max 10001 -t 0 -f 100 -ot Byte -co COMPRESS=LZW -i $INDIR_C/$tile"_class.tif" -o $INDIR/$tile"_C"$DIR"Perc.tif"
|
|
42 |
|
41 |
43 |
fi
|
42 |
44 |
|
43 |
45 |
fi
|
44 |
46 |
|
45 |
47 |
done
|
|
48 |
rm -f $OUTDIR/perc_$DIR.tif
|
|
49 |
gdal_merge.py -co COMPRESS=LZW -ot Byte -o $OUTDIR/perc_$DIR.tif $INDIR/*.tif
|
46 |
50 |
|
47 |
|
exit
|
48 |
|
|
49 |
|
|
50 |
|
gdal_merge.py -co COMPRESS=LZW -ps -0.008333333333330 -0.008333333333330 -ot Byte -o $OUTDIR/perc_$DIR.tif $INDIR/Smoothed_N*E*_C$DIR"Perc.tif" $INDIR/Smoothed_N*W*_C$DIR"Perc.tif" $INDIR/Smoothed_S*E*_C$DIR"Perc.tif" $INDIR/Smoothed_S*W*_C$DIR"Perc.tif"
|
|
51 |
if [ -f $OUTDIR/color-bw.txt ] ; then
|
|
52 |
echo the $OUTDIR/color-bw.txt exist ;
|
|
53 |
else
|
|
54 |
pkcreatect -g -min 0 -max 100 | sort -k 1,1 -rg | awk '{ print NR-1 , $2 ,$3 ,$4 ,$5 }' > $OUTDIR/color-bw.txt
|
|
55 |
fi
|
51 |
56 |
|
|
57 |
pkcreatect -ct $OUTDIR/color-bw.txt -co COMPRESS=LZW -co INTERLEAVE=BAND -d "Percent of elevation values >= ${DIR}m" -i $OUTDIR/perc_$DIR.tif -o $OUTDIR/perc_${DIR}_tmp.tif
|
|
58 |
mv $OUTDIR/perc_${DIR}_tmp.tif $OUTDIR/perc_${DIR}.tif
|
final version script gmted2010_res_x10/sc2_class_treshold_percent.sh and gmted2010_res_x10/sc3_class_treshold_density_merge.sh