1 |
73e9d9c6
|
Giuseppe
|
# calculate slope or area percent above a specific treshold eg 0-4.9 put 0 ; 5-9.9 put 5
|
2 |
|
|
# for this case the treshold is set every 5 degrees
|
3 |
|
|
# geting the integer of the altitued / 100
|
4 |
|
|
|
5 |
|
|
# ls /mnt/data/jetzlab/Data/environ/global/dem_variables/slope/tiles/Smoothed_N*E*.tif | xargs -n 1 -P 36 bash /mnt/data/jetzlab/Data/environ/global/dem_variables/scripts/sc1_slope_treshold_percent.sh
|
6 |
|
|
# too check
|
7 |
|
|
# ny=45 ; for n in `seq 1 9` ;do echo ` gdallocationinfo -valonly tiles/Smoothed_N00E005.tif 2$n $ny` `gdallocationinfo -valonly class/class/Smoothed_N00E005_class.tif 2$n $ny` ; done
|
8 |
|
|
|
9 |
|
|
export file=$1
|
10 |
|
|
export filename=`basename $file .tif`
|
11 |
|
|
(
|
12 |
|
|
INDIR=/mnt/data/jetzlab/Data/environ/global/dem_variables/slope/tiles
|
13 |
|
|
OUTDIR=/mnt/data/jetzlab/Data/environ/global/dem_variables/slope/class/class
|
14 |
|
|
|
15 |
|
|
# calcualte slope every 5 degree using the the Int16 factors
|
16 |
|
|
|
17 |
|
|
oft-calc -ot Byte $INDIR/$filename.tif $OUTDIR/$filename"_class_tmp1.tif" <<EOF
|
18 |
|
|
1
|
19 |
|
|
#1 2.5 - 5 /
|
20 |
|
|
EOF
|
21 |
|
|
|
22 |
|
|
oft-calc -inv -ot Byte $OUTDIR/$filename"_class_tmp1.tif" $OUTDIR/$filename"_class_tmp2.tif" <<EOF
|
23 |
|
|
1
|
24 |
|
|
#1 5 *
|
25 |
|
|
EOF
|
26 |
|
|
|
27 |
|
|
oft-calc -inv -ot Byte $OUTDIR/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class_tmp3.tif" <<EOF
|
28 |
|
|
1
|
29 |
|
|
#1 0 < 0 #1 ?
|
30 |
|
|
EOF
|
31 |
|
|
|
32 |
|
|
gdal_translate -co COMPRESS=LZW -co ZLEVEL=9 $OUTDIR/$filename"_class_tmp3.tif" $OUTDIR/$filename"_class.tif"
|
33 |
|
|
rm $OUTDIR/$filename"_class_tmp1.tif" $OUTDIR/$filename"_class_tmp2.tif" $OUTDIR/$filename"_class_tmp3.tif"
|
34 |
|
|
|
35 |
|
|
gdalinfo -mm $OUTDIR/$filename"_class.tif" | grep Computed | awk '{ gsub ("[=,]"," "); print int($(NF-1)), int($(NF))}' > $OUTDIR/txt/$filename"_min_max.txt"
|
36 |
|
|
|
37 |
|
|
for class in $(seq `awk '{ print $1}' $OUTDIR/txt/${filename}_min_max.txt` 5 `awk '{ print $2}' $OUTDIR/txt/${filename}_min_max.txt`) ; do
|
38 |
|
|
|
39 |
|
|
class_start=$class
|
40 |
|
|
class_end=$(awk '{ print $2}' $OUTDIR/txt/$filename"_min_max.txt")
|
41 |
|
|
class_string=$(for class_unique in $(seq $class_start 5 $class_end ) ; do echo -n "-class $class_unique " ; done)
|
42 |
|
|
|
43 |
|
|
echo applaid the filter for the classes $class_string
|
44 |
|
|
|
45 |
|
|
pkfilter -dx 10 -dy 10 $class_string -f density -d 10 -i $OUTDIR/$filename"_class.tif" -o $OUTDIR/../class$class/$filename"_C"$class"Perc.tif" -co COMPRESS=LZW -co ZLEVEL=9 -ot Byte
|
46 |
|
|
|
47 |
|
|
done
|
48 |
|
|
|
49 |
|
|
|
50 |
|
|
) 2>&1 | tee /mnt/data/jetzlab/Data/environ/global/tif_tmp/log_of_$filename".txt"
|