Project

General

Profile

Download (2.51 KB) Statistics
| Branch: | Revision:
1
# calculate altitude area percent above a specific treshold
2
# e.g  75% of class200 means that 75% of the pixels is >= 200 
3
# for this case the treshold is set every 100 meter
4
# geting the integer of the altitued / 100
5

    
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 
8
# to check 
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

    
11
export file=$1
12
export mm=$2
13
export filename=`basename $file .tif`
14
(
15

    
16
INDIR=/mnt/data2/dem_variables/GMTED2010/tiles/$mm"75_grd_tif"
17
OUTDIR=/mnt/data2/dem_variables/GMTED2010/altitude/class_$mm/class
18

    
19
echo  calcualte altitude  every 100 meter  using the the Int16 factors for $file 
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
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
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"
34

    
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

    
37
echo min and max for $OUTDIR/../tmp/$filename"_min_max_"$mm.txt
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 
41

    
42
    class_start=$class
43
    class_end=$(awk '{ print $2}'  $OUTDIR/../tmp/${filename}_min_max_${mm}.txt)
44
    class_string=$(for class_unique in $(seq $class_start 100  $class_end  ) ; do echo -n "-class $class_unique "  ; done) 
45

    
46
    echo applaid the filter for the classes  $class_string
47

    
48
    pkfilter -dx 4 -dy 4 $class_string -f density -d 4 -i $OUTDIR/$filename"_class.tif" -o $OUTDIR/../class$class/$filename"_C"$class"Perc.tif" -co COMPRESS=LZW -co ZLEVEL=9 -ot Byte 
49

    
50
done 
51

    
52

    
53
) 2>&1 | tee  /mnt/data2/dem_variables/GMTED2010/log/log_of_class_$mm"_"$filename".txt"
(3-3/5)