-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmakeSection.sh
executable file
·53 lines (50 loc) · 1.38 KB
/
makeSection.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
#/bin/sh!
$file
file=$1
no_lines=$(cat $file| wc -l)
rm -rf profileData
mkdir profileData
rm temp.txt
touch temp.txt
for j in $(seq 1 $2)
do
g.region raster=DTM$j
inc=0
if [ $(($no_lines%2)) -eq 0 ]
then
name=0
for i in $(seq 1 2 $no_lines)
do
last=$i
last=$((last+1))
data=$(awk "NR>=$i&&NR<=$last" $file)
var1=$(echo $data | cut -d' ' -f1)
var2=$(echo $data | cut -d' ' -f2)
x1=$(echo $var1 | cut -d',' -f1)
y1=$(echo $var1 | cut -d',' -f2)
x2=$(echo $var2 | cut -d',' -f1)
y2=$(echo $var2 | cut -d',' -f2)
echo "x1: " $x1 " y1: " $y1
echo "x2: " $x2 " y2: " $y2
output_file="$name"".txt"
echo "output file: "$output_file
r.profile input="DTM$j" coordinates=$x1,$y1,$x2,$y2 output="temp.txt" --overwrite
a=1
while read line
do
if [[ "$line" == *"*"* ]]
then
a=0
fi
done<temp.txt
if [ $(($a)) -eq 1 ]
then
cp temp.txt profileData/$output_file
fi
name=$(($name+15))
done
else
echo "Odd number of lines"
fi
done
rm temp.txt