-
-
Notifications
You must be signed in to change notification settings - Fork 291
/
rhemisphere.sh
executable file
·49 lines (35 loc) · 1.08 KB
/
rhemisphere.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
#!/bin/sh
# Markus Neteler, 2006
# This program is free software under the GNU General Public
# License (>=v2). Read the file COPYING that comes with GRASS
# for details.
# Test cases for 2D raster data
# generate a hemisphere to test slope, aspect, curvatures
# some definitions:
BOXLENGTH=1000 # side length of test area
RADIUS=500 # half BOXLENGTH
############
if [ -z "$GISBASE" ] ; then
echo "You must be in GRASS GIS to run this program." >&2
exit 1
fi
# some functions - keep order here
TMP="disk.$$"
cleanup()
{
echo "Removing temporary map"
g.remove --q -f type=raster name=$TMP > /dev/null
}
########################
g.region n=$BOXLENGTH s=0 w=0 e=$BOXLENGTH -p res=1
X="(col() - $RADIUS)"
Y="($RADIUS - row())"
r="sqrt($X^2 + $Y^2)"
#Mask out unwanted parts (check for <= ??):
r.mapcalc "$TMP = if($r<$RADIUS,$r,null())"
ALPHA="acos ($TMP/$RADIUS)"
HEIGHT="$RADIUS * sin($ALPHA)"
r.mapcalc "hemisphere = $HEIGHT"
cleanup
g.message "Generated raster map <hemisphere>"
#echo "Now generate aspect + slope on <hemisphere>"