-
Notifications
You must be signed in to change notification settings - Fork 0
/
ALL.sh
executable file
·135 lines (102 loc) · 3 KB
/
ALL.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
#!/bin/bash
yrs="PAPER"
cns="B1
B2
B3
B4
B5
B6_VCID_1
B6_VCID_2
B7
B8"
toas="red
green
blue
nir
swir1
swir2"
MONOMASK="./MASK/zapoved.shp"
MULTMASK="./MASK/zapoved.shp"
LANDSAT7MASK="./MASK/landsat.shp"
function landsat7gap_mask(){
gzip -d ./$yr/$step/gap_mask/*.TIF.gz
for cn in $cns
do
if [ -f ./$yr/$step/gap_mask/${nam}_GM_${cn}.TIF ]; then
echo masking - ${nam}_${cn}
gdal_fillnodata.py -mask ./$yr/$step/gap_mask/${nam}_GM_${cn}.TIF -of GTiff \
./$yr/$step/${nam}_${cn}.TIF \
./$yr/$step/${nam}_${cn}_mask.TIF
mkdir -p ./$yr/$step/backup/gap_mask
mv ./$yr/$step/${nam}_${cn}.TIF ./$yr/$step/backup/${nam}_${cn}.TIF
mv ./$yr/$step/gap_mask/${nam}_GM_${cn}.TIF ./$yr/$step/backup/gap_mask/${nam}_GM_${cn}.TIF
gdalwarp -cutline $LANDSAT7MASK -crop_to_cutline \
./$yr/$step/${nam}_${cn}_mask.TIF \
./$yr/$step/${nam}_${cn}.TIF
rm -f ./$yr/$step/${nam}_${cn}_mask.TIF
fi
done
gzip -a ./$yr/$step/backup/gap_mask/*.TIF
rmdir ./$yr/$step/gap_mask
}
function normalization(){
echo normalization scene - ${mtl}
/usr/bin/python2 calc_norm.py ./$yr/$step/$mtl ./horizons_results.txt
}
function cut_mask(){
for toa in $toas
do
echo cut to mask - ${nam}_${toa}
gdalwarp -cutline $MONOMASK -crop_to_cutline \
./$yr/$step/${toa}.tif \
./$yr/$step/${toa}_mono.tif
gdalwarp -cutline $MULTMASK -crop_to_cutline \
./$yr/$step/${toa}.tif \
./$yr/$step/${toa}_mult.tif
rm -f ./$yr/$step/${toa}.tif
mv ./$yr/$step/${toa}_mono.tif ./$yr/$step/${toa}.tif
done
}
function multi_raster(){
echo create multiraster
gdal_merge.py ./$yr/$step/red_mult.tif \
./$yr/$step/green_mult.tif \
./$yr/$step/blue_mult.tif \
./$yr/$step/nir_mult.tif \
./$yr/$step/swir1_mult.tif \
./$yr/$step/swir2_mult.tif \
-o ./$yr/$step/multichannel.tif -separate
rm ./$yr/$step/red_mult.tif
rm ./$yr/$step/green_mult.tif
rm ./$yr/$step/blue_mult.tif
rm ./$yr/$step/nir_mult.tif
rm ./$yr/$step/swir1_mult.tif
rm ./$yr/$step/swir2_mult.tif
}
function index(){
echo normalization scene - ${mtl}
/usr/bin/python2 calc_raster.py ./$yr/$step
}
for yr in $yrs
do
steps=`ls -1 ./${yr}`
for step in $steps
do
mtl=`ls ./$yr/$step | grep _MTL.txt`
echo $mtl
nam=`echo ${mtl}| awk -F "_" '{print $1}'`
echo $yr
echo $step
echo $nam
#gap mask for lansat 7
landsat7gap_mask
#Lansat normalization
normalization
#cut raster to mask
cut_mask
#multichannel raster
multi_raster
#sreate indexs
index
done
done