blob: e1781832784135de22df91826db7c20b3196729e (
plain) (
blame)
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
|
#!/bin/bash
set -e
################################################################################
# Configuration
################################################################################
PROJECT_ROOT=
# Location to create contour of, e.g. N47E008
LOCATION=
# (Linear contour lines) Difference in elevation between contour lines, e.g. 100
ELEV=
# (Exponential contour lines) The exponential base to use for drawing contour
# lines at expoential intervals, e.g. 1.1
BASE=
# Offset from sea-level to use when drawing contour lines, e.g. 400
OFFSET=
# Colours given in RGB or RGBA hex values, e.g. red, #f00, or #00000000
FG_COLOUR=
BG_COLOUR=
# Given in float, e.g. 0.12
LINE_THICKNESS=
# Used for downloading the data from NASA
EARTHDATA_USERNAME=
EARTHDATA_PASS=
################################################################################
cd "$PROJECT_ROOT"
if [[ ! -r "data/$LOCATION.SRTMGL1.hgt.zip" ]]
then
cd data
wget \
--quiet \
--show-progress \
--continue \
--user="$EARTHDATA_USERNAME" \
--password="$EARTHDATA_PASS" \
"https://e4ftl01.cr.usgs.gov//DP133/SRTM/SRTMGL1.003/2000.02.11/$LOCATION.SRTMGL1.hgt.zip"
cd ..
fi
if [[ ! -r "data/$LOCATION.hgt" ]]
then
cd data
unzip "$LOCATION.SRTMGL1.hgt.zip"
cd ..
fi
SIGMA=50
KERNEL=100
ORIGINAL=$PROJECT_ROOT/data/$LOCATION.hgt
SMOOTHED=$PROJECT_ROOT/data/$LOCATION-s$SIGMA-r$KERNEL.sdat
CONTOUR_LIN=$PROJECT_ROOT/gdal_contours/linear-${ELEV}m-$LOCATION-s$SIGMA-r$KERNEL.gpkg
CONTOUR_EXP=$PROJECT_ROOT/gdal_contours/exp-$BASE-offset-$OFFSET-$LOCATION-s$SIGMA-r$KERNEL.gpkg
if ! [[ -r "$SMOOTHED" ]]
then
saga_cmd grid_filter "Gaussian Filter" \
-INPUT "$ORIGINAL" \
-SIGMA "$SIGMA" \
-KERNEL_TYPE 0 \
-KERNEL_RADIUS "$KERNEL" \
-RESULT "$SMOOTHED"
fi
if ! [[ -r "$CONTOUR_LIN" ]]
then
gdal_contour -a ELEV -i "$ELEV" -f "GPKG" "$SMOOTHED" "$CONTOUR_LIN"
fi
if ! [[ -r "$CONTOUR_EXP" ]]
then
gdal_contour -e ELEV -off "$OFFSET" -e "$BASE" -f "GPKG" "$SMOOTHED" "$CONTOUR_EXP"
fi
python3 contour.py "$CONTOUR_EXP" "${CONTOUR_EXP/%gpkg/png}" "$FG_COLOUR" "$BG_COLOUR" "$LINE_THICKNESS"
python3 contour.py "$CONTOUR_LIN" "${CONTOUR_LIN/%gpkg/png}" "$FG_COLOUR" "$BG_COLOUR" "$LINE_THICKNESS"
|