3
############################################################################
5
# MODULE: r.plane for GRASS 5.7; based on r.plane for GRASS 5
6
# AUTHOR(S): CERL?; updated to GRASS 5.7 by Michael Barton
7
# Dec 2004: Alessandro Frigeri & Ivan Marchesini
8
# Modified to produce floating and double values maps
9
# Converted to Python by Glynn Clements
10
# PURPOSE: Creates a raster plane map from user specified inclination and azimuth
11
# COPYRIGHT: (C) 2004-2012 by the GRASS Development Team
13
# This program is free software under the GNU General Public
14
# License (>=v2). Read the file COPYING that comes with GRASS
17
#############################################################################
20
#% description: Creates raster plane map given dip (inclination), aspect (azimuth) and one point.
24
#%option G_OPT_R_OUTPUT
31
#% description: Dip of plane in degrees
39
#% description: Azimuth of the plane in degrees
45
#% description: Easting coordinate of a point on the plane
51
#% description: Northing coordinate of a point on the plane
57
#% description: Elevation coordinate of a point on the plane
63
#% options: CELL,FCELL,DCELL
64
#% description: Type of raster map to be created
72
import grass.script as grass
75
name = options['output']
76
type = options['type']
77
dip = float(options['dip'])
78
az = float(options['azimuth'])
79
ea = float(options['easting'])
80
no = float(options['northing'])
81
el = float(options['elevation'])
85
### test input values ###
87
grass.fatal(_("dip must be between -90 and 90."))
89
if az < 0 or az >= 360:
90
grass.fatal(_("azimuth must be between 0 and 360"))
92
### now the actual algorithm
93
az_r = math.radians(-az)
94
sinaz = math.sin(az_r)
95
cosaz = math.cos(az_r)
97
dip_r = math.radians(-dip)
98
tandip = math.tan(dip_r)
102
kz = el - ea * sinaz * tandip - no * cosaz * tandip
107
elif type == "FCELL":
114
grass.mapcalc("$name = $type($round(x() * $kx + y() * $ky + $kz))",
115
name = name, type = dtype, round = round, kx = kx, ky = ky, kz = kz)
117
grass.run_command('r.support', map = name, history = '')
118
grass.raster_history(name)
120
grass.message(_("Done."))
121
t = string.Template("Raster map <$name> generated by r.plane " +
122
"at point $ea E, $no N, elevation $el with dip = $dip degrees and " +
123
"aspect = $az degrees ccw from north.")
124
grass.message(t.substitute(name = name, ea = ea, no = no, el = el, dip = dip, az = az))
126
if __name__ == "__main__":
127
options, flags = grass.parser()