2
# Parameters: 1, 2, 3 - number of LANDSAT band
3
# written by Markus Neteler 21. Jul. 1998, 5. Jan. 1999
4
# neteler geog.uni-hannover.de | neteler itc.it
9
g.message -e "You must use i.oif instead of i.oifcalc (this is a submodule)"
13
if [ $1 -lt 1 ] || [ $1 -gt 7 ] || [ $2 -lt 1 ] || [ $2 -gt 7 ] || [ $3 -lt 1 ] || [ $3 -gt 7 ] ; then
14
g.message -e "Invalid channel combination ($1 $2 $3)"
20
#### check if we have awk
21
if [ ! -x "`which awk`" ] ; then
22
g.message -e "awk required, please install awk or gawk first"
26
# setting environment, so that awk works properly in all languages
31
# calculate SUM of Stddeviations:
32
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $1 > "$temp_sum"
33
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $2 >> "$temp_sum"
34
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_stddev" 1 $3 >> "$temp_sum"
36
cat "$temp_sum" | awk -v temp_file="$temp_calc" \
44
# calculate SUM of absolute(Correlation values):
45
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $2 > "$temp_sum"
46
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $1 $3 >> "$temp_sum"
47
"$GISBASE"/etc/i.oif/m.cutmatrix "$temp_correlation" $2 $3 >> "$temp_sum"
49
cat "$temp_sum" | awk -v temp_file="$temp_calc" \
52
{sum += sqrt($1*$1) ; N++} # sqrt(x^2) is my ABS-function
54
print sum >> temp_file
57
# Calculate OIF index:
58
# Divide (SUM of Stddeviations) and (SUM of Correlation)
59
cat "$temp_calc" | awk 'BEGIN {}
60
{count = divisor; divisor = $1;} # value shift - no better idea ;-)