Project

General

Profile

« Previous | Next » 

Revision 9ceb3a6c

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

final version of gmted2010_res_x10/sc2a_dem_variables.sh

View differences:

terrain/procedures/dem_variables/gmted2010_res_x10/sc2a2_layer_evaluation.sh
1
# calculate pearson cofficent between the EARTHENV-DEM90 and GMTED2010 derived topographic variables
2
# be	Breakline Emphasis     
3
# ds	Systematic Subsample   
4
# md	Median Statistic       
5
# mi	Minimum Statistic      
6
# mn	Mean Statistic         
7
# mx	Maximum Statistic      
8
# sd	Standard Dev. Statistic
9

  
10
gdal_translate  -projwin  $(getCorners4Gtranslate GMTED2010/roughness/median/tiles/5_1_be.tif) resol_x10/roughness/median/roughness_median.tif resol_x10/roughness/median/roughness_median-clip.tif
11

  
12
gdal_merge.py  -separate  -o 5_1_be_merge.tif   5_1_be.tif /mnt/data2/dem_variables/resol_x10/roughness/median/roughness_median-clip.tif
13
gdal_merge.py  -separate  -o 5_1_ds_merge.tif   5_1_ds.tif /mnt/data2/dem_variables/resol_x10/roughness/median/roughness_median-clip.tif
14
gdal_merge.py  -separate  -o 5_1_md_merge.tif   5_1_md.tif /mnt/data2/dem_variables/resol_x10/roughness/median/roughness_median-clip.tif
15
gdal_merge.py  -separate  -o 5_1_mn_merge.tif   5_1_mn.tif /mnt/data2/dem_variables/resol_x10/roughness/median/roughness_median-clip.tif
16

  
17
oft-pearson.bash 5_1_be_merge.tif 5_1_be_merge.txt
18
oft-pearson.bash 5_1_ds_merge.tif 5_1_ds_merge.txt
19
oft-pearson.bash 5_1_md_merge.tif 5_1_md_merge.txt
20
oft-pearson.bash 5_1_mn_merge.tif 5_1_mn_merge.txt
21

  
22
# results 
23
# GMTED2010 -  250 EARTHENV-DEM90 – 90m 
24
# 1km-median (Roughness of Systematic Subsample ) 1km-median (Roughness of  -DEM90)  0.989316
25
# 1km-median (Roughness of Median Statistic)      1km-median (Roughness of  -DEM90)  0.988585
26
# 1km-median (Roughness of Mean Statistic)        1km-median (Roughness of  -DEM90)  0.987848
27
# 1km-median (Roughness of Breakline Emphasis )   1km-median (Roughness of  -DEM90)  0.982874
28

  
29

  
30
cd /mnt/data2/dem_variables/GMTED2010/tpi/median/tiles
31

  
32
gdal_translate -projwin $(getCorners4Gtranslate /mnt/data2/dem_variables/GMTED2010/tpi/median/tiles/5_1_be.tif) /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median.tif /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median-clip.tif
33

  
34
gdal_merge.py  -separate  -o 5_1_be_merge.tif   5_1_be.tif /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median-clip.tif
35
gdal_merge.py  -separate  -o 5_1_ds_merge.tif   5_1_ds.tif /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median-clip.tif
36
gdal_merge.py  -separate  -o 5_1_md_merge.tif   5_1_md.tif /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median-clip.tif
37
gdal_merge.py  -separate  -o 5_1_mn_merge.tif   5_1_mn.tif /mnt/data2/dem_variables/resol_x10/tpi/median/tpi_median-clip.tif
38

  
39
oft-pearson.bash 5_1_be_merge.tif 5_1_be_merge.txt
40
oft-pearson.bash 5_1_ds_merge.tif 5_1_ds_merge.txt
41
oft-pearson.bash 5_1_md_merge.tif 5_1_md_merge.txt
42
oft-pearson.bash 5_1_mn_merge.tif 5_1_mn_merge.txt
43

  
44
# results 
45
# GMTED2010 -  250 EARTHENV-DEM90 – 90m
46

  
47
# 1km-median (tpi of Median Statistic)      1km-median (tpi of  -DEM90)   0.798472
48
# 1km-median (tpi of Mean Statistic)        1km-median (tpi of  -DEM90)   0.793509
49
# 1km-median (tpi of Systematic Subsample ) 1km-median (tpi of  -DEM90)   0.792891
50
# 1km-median (tpi of Breakline Emphasis )   1km-median (tpi of  -DEM90)   0.639219
51

  
52
cd /mnt/data2/dem_variables/GMTED2010/tri/median/tiles
53
gdal_translate -projwin $(getCorners4Gtranslate /mnt/data2/dem_variables/GMTED2010/tri/median/tiles/5_1_be.tif) /mnt/data2/dem_variables/resol_x10/tri/median/tri_median.tif /mnt/data2/dem_variables/resol_x10/tri/median/tri_median-clip.tif
54

  
55
gdal_merge.py  -separate  -o 5_1_be_merge.tif   5_1_be.tif /mnt/data2/dem_variables/resol_x10/tri/median/tri_median-clip.tif
56
gdal_merge.py  -separate  -o 5_1_ds_merge.tif   5_1_ds.tif /mnt/data2/dem_variables/resol_x10/tri/median/tri_median-clip.tif
57
gdal_merge.py  -separate  -o 5_1_md_merge.tif   5_1_md.tif /mnt/data2/dem_variables/resol_x10/tri/median/tri_median-clip.tif
58
gdal_merge.py  -separate  -o 5_1_mn_merge.tif   5_1_mn.tif /mnt/data2/dem_variables/resol_x10/tri/median/tri_median-clip.tif
59

  
60
oft-pearson.bash 5_1_be_merge.tif 5_1_be_merge.txt
61
oft-pearson.bash 5_1_ds_merge.tif 5_1_ds_merge.txt
62
oft-pearson.bash 5_1_md_merge.tif 5_1_md_merge.txt
63
oft-pearson.bash 5_1_mn_merge.tif 5_1_mn_merge.txt
64

  
65
# results 
66
# GMTED2010 -  250 EARTHENV-DEM90 – 90m 
67
# 1km-median (tri of Median Statistic)      1km-median (tri of  -DEM90)  0.990189
68
# 1km-median (tri of Systematic Subsample ) 1km-median (tri of  -DEM90)  0.990139
69
# 1km-median (tri of Mean Statistic)        1km-median (tri of  -DEM90)  0.989568
70
# 1km-median (tri of Breakline Emphasis )   1km-median (tri of  -DEM90)  0.98115
71

  
72

  
73
# therefore the GMTED2010  Median Statistic is consider the one that better capture the altitude  variation to derive topographic variables  
terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh
1
# variables derived from the dem following commands in http://www.gdal.org/gdaldem.html#gdaldem_slope 
2
# to check ls *.tif  | xargs -n 1 -P 30 bash -c $' gdalinfo  -mm $1 |grep Max  | awk \'{ gsub("[=,]", " ") ;  print $3,$4  }\'  ' _ 
3

  
4
# find /mnt/data2/dem_variables/GMTED2010/{aspect,roughness,slope,tpi,tri}  -name *.tif | xargs -n 1 -P 10 rm ; 
5

  
6
# be, ds, md, mn  ; Breakline Emphasis, Systematic Subsample, Median Statistic, Mean Statistic  ; md ds 
7
# for file in `ls /mnt/data2/dem_variables/GMTED2010/tiles/be75_grd_tif/*.tif` ; do echo $file md ; done  | xargs -n 2 -P 5 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh ; 
8
# for file in `ls /mnt/data2/dem_variables/GMTED2010/tiles/be75_grd_tif/*.tif` ; do echo $file ds ; done  | xargs -n 2 -P 5 bash /mnt/data2/dem_variables/scripts/environmental-layers/terrain/procedures/dem_variables/gmted2010_res_x10/sc2a_dem_variables.sh 
9

  
10
export file=$1
11
export mm=$2
12
export INDIR=/mnt/data2/dem_variables/GMTED2010/tiles/${mm}75_grd_tif
13
export OUTDIR=/mnt/data2/dem_variables/GMTED2010
14

  
15
export filename=`basename $file .tif`
16

  
17
( 
18

  
19
echo altitude variables with file    $INDIR/$filename.tif 
20

  
21
#  median 
22
pkfilter -m -32768   -dx 4 -dy 4   -f median -d 4 -i  $INDIR/$filename.tif    -o  $OUTDIR/altitude/median/tiles/${filename}_${mm}.tif     -co COMPRESS=LZW -ot Int16  
23
# stdev
24
pkfilter -m -32768 -dx 4 -dy 4   -f var -d 4 -i $INDIR/$filename.tif   -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32   # max 1552385.000 sqrt(1245.947)
25
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/altitude/stdev/tiles/${filename}_${mm}.tif
26
rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
27
# min 
28
pkfilter -m -32768  -dx 4 -dy 4   -f min -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
29
# max
30
pkfilter -m -32768 -dx 4 -dy 4   -f max -d 4 -i $INDIR/$filename.tif    -o  $OUTDIR/altitude/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16  
31
# mean
32
pkfilter -m -32768 -dx 4 -dy 4   -f mean -d 4 -i $INDIR/$filename.tif   -o  $OUTDIR/altitude/mean/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW  -ot Int16  
33

  
34
# starting to use gdaldem to compute variables. Gdaldem use -9999 as no data. 
35

  
36
echo  slope with file   $INDIR/$filename.tif
37
gdaldem slope  -s 111120 -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/slope/tiles/${filename}_${mm}.tif  # -s to consider xy in degree and z in meters
38
# slope median 
39
pkfilter -m -9999 -dx 4 -dy 4 -f median  -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o $OUTDIR/slope/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Byte
40
# slope stdev 
41
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o   /tmp/ramdisk/tmp_${filename}_${mm}.tif  -ot Int32
42
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/slope/stdev/tiles/${filename}_${mm}.tif
43
rm -f /tmp/ramdisk/tmp_${filename}_${mm}.tif
44
# slope min 
45
pkfilter -m -9999  -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
46
# slope max
47
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW   -ot Byte 
48
# slope mean
49
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/slope/tiles/${filename}_${mm}.tif -o  $OUTDIR/slope/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW  -ot Byte 
50

  
51
# rm -f  $OUTDIR/slope/tiles/$filename.tif
52

  
53
echo  generate a Terrain Ruggedness Index TRI  with file   $file
54
gdaldem TRI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tri/tiles/${filename}_${mm}.tif
55
# tri median 
56
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o $OUTDIR/tri/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
57
# tri stdev 
58
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4    -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  /tmp/ramdisk/tmp_${filename}_${mm}.tif
59
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int16 --overwrite --outfile $OUTDIR/tri/stdev/tiles/${filename}_${mm}.tif
60
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
61
# tri min 
62
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/min/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16  
63
# tri max
64
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/max/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
65
# tri mean
66
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tri/tiles/${filename}_${mm}.tif -o  $OUTDIR/tri/mean/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
67

  
68
# rm -f  $OUTDIR/tri/tiles/$filename.tif
69

  
70
echo  generate a Topographic Position Index TPI  with file   $INDIR/$filename.tif
71

  
72
gdaldem TPI  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/tpi/tiles/${filename}_${mm}.tif      # tpi has negative number 
73

  
74
oft-calc -ot Float32   $OUTDIR/tpi/tiles/${filename}_${mm}.tif $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  &> /dev/null    <<EOF
75
1
76
#1 10 *
77
EOF
78

  
79
# tpi median 
80
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o $OUTDIR/tpi/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
81
echo tpi stdev 
82
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif"  -o /tmp/ramdisk/tmp_${filename}_${mm}.tif 
83
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif  --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/tpi/stdev/tiles/${filename}_${mm}.tif
84
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
85
# tpi min 
86
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/min/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
87
# tpi max
88
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4  -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/max/tiles/${filename}_${mm}.tif   -co COMPRESS=LZW -ot Int16
89
# tpi mean
90
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/tpi/tiles/${filename}_${mm}"_t10.tif" -o $OUTDIR/tpi/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
91

  
92

  
93
echo  generate roughness   with file   $INDIR/$filename.tif
94

  
95
gdaldem  roughness  -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/roughness/tiles/${filename}_${mm}.tif
96

  
97
# roughness median 
98
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/median/tiles/${filename}_${mm}.tif -co COMPRESS=LZW -ot Int16
99
echo roughness stdev 
100
pkfilter -m -9999 -dx 4 -dy 4 -f var  -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o /tmp/ramdisk/tmp_${filename}_${mm}.tif  
101
gdal_calc.py -A  /tmp/ramdisk/tmp_${filename}_${mm}.tif --calc="sqrt(A)" --type Int32 --overwrite --outfile $OUTDIR/roughness/stdev/tiles/${filename}_${mm}.tif
102
rm -f  /tmp/ramdisk/tmp_${filename}_${mm}.tif
103
# roughness min 
104
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/min/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
105
# roughness max
106
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/max/tiles/${filename}_${mm}.tif    -co COMPRESS=LZW -ot Int16
107
# roughness mean
108
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i $OUTDIR/roughness/tiles/${filename}_${mm}.tif -o $OUTDIR/roughness/mean/tiles/${filename}_${mm}.tif  -co COMPRESS=LZW -ot Int16
109

  
110
# rm -f   $OUTDIR/roughness/tiles/${filename}_${mm}.tif
111

  
112

  
113
echo  aspect  with file   $INDIR/$filename.tif
114

  
115
gdaldem aspect  -zero_for_flat -co COMPRESS=LZW   $INDIR/$filename.tif  $OUTDIR/aspect/tiles/${filename}_${mm}.tif
116

  
117
# r1 aspect , r2 slope 
118

  
119
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(sin(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" --overwrite --type Float32
120
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/aspect/tiles/${filename}_${mm}.tif --calc="(cos(A))" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" --overwrite --type Float32
121

  
122
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/slope/tiles/${filename}_${mm}.tif -B  $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif"  --calc="((sin(A))*B)" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" --overwrite --type Float32
123
gdal_calc.py --NoDataValue -9999 -A $OUTDIR/slope/tiles/${filename}_${mm}.tif -B  $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif"  --calc="((sin(A))*B)" --outfile   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" --overwrite --type Float32
124

  
125
echo  aspect sin   cos  Ew  Nw   median 
126
# sin
127
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
128
oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null    <<EOF
129
1
130
#1 10000 *
131
EOF
132
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_sin_t10k.tif"  
133
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
134
# cos
135
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
136
oft-calc  -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_f.tif"  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
137
1
138
#1 10000 *
139
EOF
140
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_cos_t10k.tif" 
141
rm  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
142
# Ew
143
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
144
oft-calc -ot Int16   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null   <<EOF
145
1
146
#1 10000 *
147
EOF
148
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Ew_t10k.tif" 
149
rm  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
150
# Nw
151
pkfilter -m -9999 -dx 4 -dy 4 -f median -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
152
oft-calc  -ot Int16  $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
153
1
154
#1 10000 *
155
EOF
156
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/median/tiles/${filename}_${mm}"_Nw_t10k.tif" 
157
rm  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
158

  
159

  
160
echo aspect sin   cos  Ew  Nw   mean
161
# sin
162
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
163
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" &> /dev/null  <<EOF
164
1
165
#1 10000 *
166
EOF
167
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_sin_t10k.tif"  
168
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
169
# cos
170
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
171
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_f.tif"  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null   <<EOF
172
1
173
#1 10000 *
174
EOF
175
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_cos_t10k.tif" 
176
rm  /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
177
# Ew
178
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
179
oft-calc -ot Int16   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"  &> /dev/null  <<EOF
180
1
181
#1 10000 *
182
EOF
183
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Ew_t10k.tif" 
184
rm  /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
185
# Nw
186
pkfilter -m -9999 -dx 4 -dy 4 -f mean -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
187
oft-calc  -ot Int16  $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_f.tif"  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
188
1
189
#1 10000 *
190
EOF
191
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
192
1
193
#1 10000 *
194
EOF
195
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/mean/tiles/${filename}_${mm}"_Nw_t10k.tif" 
196
rm  /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
197

  
198
echo aspect sin   cos  Ew  Nw   max
199
# sin
200
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
201
oft-calc -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_f.tif"  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"   &> /dev/null  <<EOF
202
1
203
#1 10000 *
204
EOF
205
gdal_translate  -co COMPRESS=LZW  -ot Int16 /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_sin_t10k.tif"  
206
rm  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
207
# cos
208
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
209
oft-calc  -ot Int16  $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_f.tif"   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
210
1
211
#1 10000 *
212
EOF
213
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_cos_t10k.tif" 
214
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
215
# Ew
216
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
217
oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
218
1
219
#1 10000 *
220
EOF
221
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Ew_t10k.tif" 
222
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
223
# Nw
224
pkfilter -m -9999 -dx 4 -dy 4 -f max -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
225
oft-calc  -ot Int16   $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
226
1
227
#1 10000 *
228
EOF
229
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/max/tiles/${filename}_${mm}"_Nw_t10k.tif" 
230
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
231

  
232
echo aspect sin   cos  Ew  Nw   min 
233
# sin
234
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
235
oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_f.tif"   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"  &> /dev/null   <<EOF
236
1
237
#1 10000 *
238
EOF
239
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_sin_t10k.tif"  
240
rm   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
241
# cos
242
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
243
oft-calc  -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_f.tif"   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"  &> /dev/null  <<EOF
244
1
245
#1 10000 *
246
EOF
247
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_cos_t10k.tif" 
248
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
249
# Ew
250
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
251
oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" &> /dev/null   <<EOF
252
1
253
#1 10000 *
254
EOF
255
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Ew_t10k.tif" 
256
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
257
# Nw
258
pkfilter -m -9999 -dx 4 -dy 4 -f min -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
259
oft-calc -ot Int16   $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_f.tif"   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"  &> /dev/null   <<EOF
260
1
261
#1 10000 *
262
EOF
263
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/min/tiles/${filename}_${mm}"_Nw_t10k.tif" 
264
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
265

  
266
echo aspect sin   cos  Ew  Nw   stdev
267
# stdev   
268
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_sin.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_f.tif" -co COMPRESS=LZW -ot Float32
269
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif"
270
gdal_translate  -co COMPRESS=LZW  -ot Int16  /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_sin_t10k.tif"  
271
rm   /tmp/ramdisk/${filename}_${mm}"_sin_t10k_tmp.tif" 
272
# cos
273
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_cos.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_f.tif" -co COMPRESS=LZW -ot Float32
274
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif"
275
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_cos_t10k.tif" 
276
rm   /tmp/ramdisk/${filename}_${mm}"_cos_t10k_tmp.tif" 
277
# Ew
278
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Ew.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_f.tif" -co COMPRESS=LZW -ot Float32
279
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif"
280
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Ew_t10k.tif" 
281
rm   /tmp/ramdisk/${filename}_${mm}"_Ew_t10k_tmp.tif" 
282
# Nw
283
pkfilter -m -9999 -dx 4 -dy 4 -f var -d 4 -i   $OUTDIR/aspect/tiles/${filename}_${mm}"_Nw.tif" -o   $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_f.tif" -co COMPRESS=LZW -ot Float32
284
gdal_calc.py -A  $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_f.tif"  --calc="(sqrt(A))*10000" --type Int16 --overwrite --outfile   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif"
285
gdal_translate  -co COMPRESS=LZW  -ot Int16   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" $OUTDIR/aspect/stdev/tiles/${filename}_${mm}"_Nw_t10k.tif" 
286
rm   /tmp/ramdisk/${filename}_${mm}"_Nw_t10k_tmp.tif" 
287

  
288
) 2>&1 | tee  /mnt/data2/dem_variables/GMTED2010/log_${mm}.txt
terrain/procedures/dem_variables/gmted2010_res_x10/wget.sh
1

  
2
# seq 2001 2012 | xargs -n 1 -P 10  bash /mnt/data/jetzlab/Data/environ/global/MODIS/wget.sh
3
# echo 2012  | xargs -n 1 -P 10  bash /mnt/data/jetzlab/Data/environ/global/MODIS/wget.sh
4

  
5
YEAR=$1
6
OUTDIR=/mnt/data/jetzlab/Data/environ/global/MODIS/MCD12Q1/051/$YEAR
7

  
8
# get the file list from the ftp 
9
wget -O  -   http://e4ftl01.cr.usgs.gov/MOTA/MCD12Q1.051/$YEAR.01.01/  > $OUTDIR/list_$YEAR.txt 
10

  
11
# manipulate to get just the file name 
12

  
13
grep hdf  $OUTDIR/list_$YEAR.txt   | grep -v xml | awk '{ gsub("[\"]", " ") ;  print $10 }' > $OUTDIR/list_hdf_$YEAR.txt 
14

  
15
# starting the downloding procedure and tif conversion. 
16
for file in `cat $OUTDIR/list_hdf_$YEAR.txt` ; do 
17
    filename=`basename $file .hdf`
18
    LD_PRELOAD=/usr/local/lib/vsipreload.so gdal_translate  -co COMPRESS=LZW   HDF4_EOS:EOS_GRID:"\"""/vsicurl/http://e4ftl01.cr.usgs.gov/MOTA/MCD12Q1.051/$YEAR.01.01/${file}""\"":MOD12Q1:Land_Cover_Type_1 $OUTDIR/$filename.tif 
19
    rm $OUTDIR/$filename.tif.aux.xml
20
done 
21

  
22
# merge all the data 
23

  
24
gdal_merge.py  -o $OUTDIR/../MCD12Q1_051_$YEAR"_tmp".tif  $(ls  $OUTDIR/*.tif) 
25

  
26
oft-calc -inv $OUTDIR/../MCD12Q1_051_$YEAR"_tmp".tif $OUTDIR/../MCD12Q1_051_$YEAR"_tmp2".tif  <<EOF
27
1
28
#1 254 > 0 #1 ?
29
EOF
30

  
31
gdal_translate -co COMPRESS=LZW  $OUTDIR/../MCD12Q1_051_$YEAR"_tmp2".tif   $OUTDIR/../MCD12Q1_051_$YEAR.tif 
32

  
33
$OUTDIR/../MCD12Q1_051_$YEAR"_wgs84_tmp.tif"
34
gdalwarp -rn -multi  -co COMPRESS=LZW  -t_srs   EPSG:4326  $OUTDIR/../MCD12Q1_051_$YEAR.tif   $OUTDIR/../MCD12Q1_051_$YEAR"_wgs84_tmp.tif"
35
gdal_translate -co COMPRESS=LZW    $OUTDIR/../MCD12Q1_051_$YEAR"_wgs84_tmp.tif"   $OUTDIR/../MCD12Q1_051_$YEAR"_wgs84.tif"
36
rm $OUTDIR/../M*tm*.tif
37

  
38

  
39

  
40

  
41

  

Also available in: Unified diff