[GRASS-user] How to find out an angle between to points on the map (for r.plane, r.lake)

Hi
I want to work with r.plane and r.lake to get simulate floodings in DTMs.

In the section of interest there is a river which runs from about SSW to NNE. For r.plane I need the
azimuth. Is there a tool in GRASS which tells me the angle between two
points I mark on the map like I can measure in between two points with d.measure?

Could you recommend other tools to simulate flooding events in GRASS?

Thank you
cheers
Philipp

On Thu, Feb 28, 2008 at 5:55 PM, Philipp Steigenberger
<userlist@online.de> wrote:

Could you recommend other tools to simulate flooding events in GRASS?

Last week, at the IX Meeting degli Utenti Italiani di GRASS - GFOSS in Perugia,
a new approach was presented:
http://www.grassmeeting2008.unipg.it/?q=node/70

(in funny English:
http://translate.google.com/translate?sourceid=mozclient&u=http%3A//www.grassmeeting2008.unipg.it/%3Fq%3Dnode/70
). You could contact Bianca Federici for details.

Markus

On Thursday 28 February 2008, Philipp Steigenberger wrote:

Hi
I want to work with r.plane and r.lake to get simulate floodings in DTMs.

In the section of interest there is a river which runs from about SSW to
NNE. For r.plane I need the
azimuth. Is there a tool in GRASS which tells me the angle between two
points I mark on the map like I can measure in between two points with
d.measure?

Simple trigonometry is a start. Or on a computer the atan2() function is
useful:

atan2( (end_y - start_y) , (end_x - start_x) ) * 180/pi

will return the angle in degrees. The above example is from R, but the C
implementation should be similar. Check your local documentation.

It shouldn't be hard to add something like this to d.measure for interactive
estimation of bearings.

On a related note, I wrote a module for GRASS sometime ago called d.bearing
which would create a transect from a starting point, a bearing, and a
distance along the resulting line. I will dig the source out and see if it
still compiles. It might be useful to combine that functionality with what
you are talking about.

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

On Thursday 28 February 2008, Philipp Steigenberger wrote:

Hi
I want to work with r.plane and r.lake to get simulate floodings in DTMs.

In the section of interest there is a river which runs from about SSW to
NNE. For r.plane I need the
azimuth. Is there a tool in GRASS which tells me the angle between two
points I mark on the map like I can measure in between two points with
d.measure?

Well of course I had to go and try this out.

attached is a patch (against todays SVN) to optionally print the bearing
between clicks.

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

(attachments)

d.measure_bearing.patch (3.37 KB)

On Thursday 28 February 2008, Dylan Beaudette wrote:

On Thursday 28 February 2008, Philipp Steigenberger wrote:
> Hi
> I want to work with r.plane and r.lake to get simulate floodings in DTMs.
>
> In the section of interest there is a river which runs from about SSW to
> NNE. For r.plane I need the
> azimuth. Is there a tool in GRASS which tells me the angle between two
> points I mark on the map like I can measure in between two points with
> d.measure?

Well of course I had to go and try this out.

attached is a patch (against todays SVN) to optionally print the bearing
between clicks.

Dylan

And of course here is an updated patch which computes bearing from 0 (math
style North = 90 deg) or from 90 (compass style North = 0 deg).

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341

(attachments)

d.measure_bearing.patch (4.15 KB)

Dylan Beaudette wrote:

> Well of course I had to go and try this out.
>
> attached is a patch (against todays SVN) to optionally print the
> bearing between clicks.

Hi,

you should add a check so that it won't allow bogus results if the
location is in Lat/Lon:

e.g. from d.grid:
if (geogrid->answer && G_projection() == PROJECTION_LL)
  G_fatal_error(_(".. option is not available for LL projection"));

(the great circle line's bearing changes with distance along it; unless
you are interested in the rhumbline?)

for this stuff also checkout m.cogo, r.transect, r.profile,
d.rhumbline, d.geodesic

Hamish

      ____________________________________________________________________________________
Never miss a thing. Make Yahoo your home page.
http://www.yahoo.com/r/hs

Dylan Beaudette schrieb:

On Thursday 28 February 2008, Philipp Steigenberger wrote:

Hi
I want to work with r.plane and r.lake to get simulate floodings in DTMs.

In the section of interest there is a river which runs from about SSW to
NNE. For r.plane I need the
azimuth. Is there a tool in GRASS which tells me the angle between two
points I mark on the map like I can measure in between two points with
d.measure?

Simple trigonometry is a start. Or on a computer the atan2() function is useful:

atan2( (end_y - start_y) , (end_x - start_x) ) * 180/pi

Dylan Beaudette schrieb:

attached is a patch (against todays SVN) to optionally print the bearing between clicks.

Dylan

Dylan,
sorry, I have no idea how to incllude this patch to my system.
I'm neither good in R or C or Fortran or Python.

attached is a patch (against todays SVN

(Also I have problems to install the actual SVN)

But I'm used to write shell scrpits, so I wrote this one for bc.

#!/bin/sh
LIST_1=`d.what.rast -t1`
E1=`echo $LIST_1 | awk -F : '{print $1}'`
N1=`echo $LIST_1 | awk -F : '{print $2}'`

LIST_2=`d.what.rast -t1 --q`
E2=`echo $LIST_2 | awk -F : '{print $1}'`
N2=`echo $LIST_2 | awk -F : '{print $2}'`

SCALE="scale=8"
pi=$(echo "scale=10; 4 * a ( 1 )" | bc -l)

echo "epsilon = `echo "$SCALE; 360-( a ( ( $E1 - $E2 ) / ( $N1 - $N2 )
) ) * 180 / $pi" | bc -l`°"
echo "if epsilon > 360"
echo "epsilon' = `echo "$SCALE; ( a ( ( $E1 - $E2 ) / ( $N1 - $N2 ) ) )
* 180 / $pi * -1" | bc -l`°"

In GRASS I work in Transversal Mercator (Gauß-Krüger)
I know the script isn't perfect, cause it doesn't work if N1 = N2, but
for me this doesn't matter.

Philipp

On Saturday 01 March 2008, Philipp Steigenberger wrote:

Dylan Beaudette schrieb:
> On Thursday 28 February 2008, Philipp Steigenberger wrote:
>> Hi
>> I want to work with r.plane and r.lake to get simulate floodings in
>> DTMs.
>>
>> In the section of interest there is a river which runs from about SSW to
>> NNE. For r.plane I need the
>> azimuth. Is there a tool in GRASS which tells me the angle between two
>> points I mark on the map like I can measure in between two points with
>> d.measure?
>
> Simple trigonometry is a start. Or on a computer the atan2() function is
> useful:
>
> atan2( (end_y - start_y) , (end_x - start_x) ) * 180/pi

Dylan Beaudette schrieb:
> attached is a patch (against todays SVN) to optionally print the bearing
> between clicks.
>
> Dylan

Dylan,
sorry, I have no idea how to incllude this patch to my system.
I'm neither good in R or C or Fortran or Python.

> attached is a patch (against todays SVN

(Also I have problems to install the actual SVN)

But I'm used to write shell scrpits, so I wrote this one for bc.

#!/bin/sh
LIST_1=`d.what.rast -t1`
E1=`echo $LIST_1 | awk -F : '{print $1}'`
N1=`echo $LIST_1 | awk -F : '{print $2}'`

LIST_2=`d.what.rast -t1 --q`
E2=`echo $LIST_2 | awk -F : '{print $1}'`
N2=`echo $LIST_2 | awk -F : '{print $2}'`

SCALE="scale=8"
pi=$(echo "scale=10; 4 * a ( 1 )" | bc -l)

echo "epsilon = `echo "$SCALE; 360-( a ( ( $E1 - $E2 ) / ( $N1 - $N2 )
) ) * 180 / $pi" | bc -l`°"
echo "if epsilon > 360"
echo "epsilon' = `echo "$SCALE; ( a ( ( $E1 - $E2 ) / ( $N1 - $N2 ) ) )
* 180 / $pi * -1" | bc -l`°"

In GRASS I work in Transversal Mercator (Gauß-Krüger)
I know the script isn't perfect, cause it doesn't work if N1 = N2, but
for me this doesn't matter.

Philipp

Philipp,

Glad to hear that you were able to make something which worked for you. I have
submitted the patch to d.measure to the tracker, and may be integrated into
GRASS proper if it is deemed useful by the dev crowd.

Cheers,

Dylan

--
Dylan Beaudette
Soil Resource Laboratory
http://casoilresource.lawr.ucdavis.edu/
University of California at Davis
530.754.7341