Project

General

Profile

« Previous | Next » 

Revision aff1d0ea

Added by Giuseppe Amatulli (turaco-litoria) over 11 years ago

final version script gmted2010_res_x10/sc2_class_treshold_percent.sh and gmted2010_res_x10/sc3_class_treshold_density_merge.sh

View differences:

terrain/procedures/dem_variables/gmted2010_res_x10/sc2_class_treshold_percent.sh
4 4
# geting the integer of the altitued / 100
5 5

  
6 6
#  for file in /mnt/data2/dem_variables/GMTED2010/tiles/mi75_grd_tif/*.tif ; do echo $file mi ; done  | xargs -n 2 -P 25  bash /mnt/data2/dem_variables/GMTED2010/scripts/sc2_class_treshold_percent.sh 
7
# rm  /tmp/ramdisk/* ; for file in /mnt/data2/dem_variables/GMTED2010/tiles/mx75_grd_tif/*.tif ; do echo $file mx ; done  | xargs -n 2 -P 25  bash /mnt/data2/dem_variables/GMTED2010/scripts/sc2_class_treshold_percent.sh 
7
#  for file in /mnt/data2/dem_variables/GMTED2010/tiles/mx75_grd_tif/*.tif ; do echo $file mx ; done  | xargs -n 2 -P 25  bash /mnt/data2/dem_variables/GMTED2010/scripts/sc2_class_treshold_percent.sh 
8 8
# to check 
9 9
# ny=45 ; for n in `seq 1 9` ;do echo `gdallocationinfo -valonly altitude/class/5_1_class_tmp3.tif 2$n $ny` `gdallocationinfo  -valonly  tiles/mn75_grd_tif/5_1.tif 2$n $ny` ; done 
10 10

  
......
18 18

  
19 19
echo  calcualte altitude  every 100 meter  using the the Int16 factors for $file 
20 20

  
21
oft-calc  -X -ot Int16 $INDIR/$filename.tif $OUTDIR/../tmp/$filename"_class_tmp1.tif"  &> /dev/null   <<EOF
22
1
23
#1 49 - 100 /
24
EOF
21
# oft-calc  -X -ot Int16 $INDIR/$filename.tif $OUTDIR/../tmp/$filename"_class_tmp1.tif"  &> /dev/null   <<EOF
22
# 1
23
# #1 49 - 100 /
24
# EOF
25 25

  
26
oft-calc  -X -ot Int16  $OUTDIR/../tmp/$filename"_class_tmp1.tif"  $OUTDIR/../tmp/$filename"_class_tmp2.tif"    &> /dev/null   <<EOF
27
1
28
#1 100 *
29
EOF
26
# oft-calc  -X -ot Int16  $OUTDIR/../tmp/$filename"_class_tmp1.tif"  $OUTDIR/../tmp/$filename"_class_tmp2.tif"    &> /dev/null   <<EOF
27
# 1
28
# #1 100 *
29
# EOF
30 30

  
31
rm $OUTDIR/../tmp/$filename"_class_tmp1.tif" 
32
gdal_translate -co COMPRESS=LZW -co ZLEVEL=9  $OUTDIR/../tmp/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class.tif"
33
rm $OUTDIR/../tmp/$filename"_class_tmp2.tif"
31
# rm $OUTDIR/../tmp/$filename"_class_tmp1.tif" 
32
# gdal_translate -co COMPRESS=LZW -co ZLEVEL=9  $OUTDIR/../tmp/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class.tif"
33
# rm $OUTDIR/../tmp/$filename"_class_tmp2.tif"
34 34

  
35 35
gdalinfo -mm $OUTDIR/$filename"_class.tif"  | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
36 36

  
37 37
echo min and max for $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
38 38

  
39
 
40
for class in $(seq `awk '{ print $1}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt` 100  `awk '{ print $2}' $OUTDIR/../tmp/${filename}_min_max_${mm}.txt`) ; do 
39
# 
40
for class in $(seq `awk '{ print $1}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt` 100    `awk '{ print $2}' $OUTDIR/../tmp/${filename}_min_max_${mm}.txt` ) ; do 
41 41

  
42 42
    class_start=$class
43 43
    class_end=$(awk '{ print $2}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt)
terrain/procedures/dem_variables/gmted2010_res_x10/sc3_class_treshold_density_merge.sh
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 

Also available in: Unified diff