[GRASS-user] azimuth of lines with v.to.db?

I think I already asked this, but without much success, so here is:
can I use v.to.db to get the azimuth of a line? I am thinking in
lineament analysis, so it's a simple line, just two end vertices.

thanks

Carlos

--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc - Doctorate Student at IGc-USP - Brazil
Linux User #89721 - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can't stop the signal.

Carlos wrote:

I think I already asked this, but without much success, so here is:
can I use v.to.db to get the azimuth of a line? I am thinking in
lineament analysis, so it's a simple line, just two end vertices.

not directly, but you could use v.to.db to get line start and end points, then
calculate the angle by hand. Or you could copy the v.to.db slope option and
make a new azimuth option from that. It will not be very useful for lat/lon.

Hamish

ps- I once did the same for r.los

____________________________________________________________________________________
Looking for a deal? Find great prices on flights and hotels with Yahoo! FareChase.
http://farechase.yahoo.com/

On Saturday 13 October 2007, Carlos "Guâno" Grohmann wrote:

I think I already asked this, but without much success, so here is:
can I use v.to.db to get the azimuth of a line? I am thinking in
lineament analysis, so it's a simple line, just two end vertices.

thanks

Carlos

Can you calculate it from the end points ?

Like this:

http://casoilresource.lawr.ucdavis.edu/drupal/node/468

.... except that the calculation I am doing is in R. atan2() should exist in
the c library, so adding it to GRASS should be a small effort.

Dylan

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

Carlos "Guâno" Grohmann wrote:

I think I already asked this, but without much success, so here is:
can I use v.to.db to get the azimuth of a line? I am thinking in
lineament analysis, so it's a simple line, just two end vertices.

Maybe v.distance opt=to_angle? I'm saying "maybe", because
I'm not sure if I understand the description:

"to_angle: angle of linear feature in nearest point,
counterclockwise from positive x axis, in radians, which is
between -PI and PI inclusive"

Anybody knows what is "angle of linear feature in nearest
point" supposed to mean?

BTW - another thing I don't understand in v.distance is the
to_along option: "to_along: distance to the nearest point on
'from' feature along linear feature". Anybody knows if the
"linear feature" is supposed to be present in vector "from"
or vector "to"?

Maciek

This is almost what I need. I need the results to be in range 0-360,
from North. So I can get a rose diagram, with petals weighted
according to azimuth frequency or to azimuth lenght, like the
attachment.

cheers

Carlos

On 10/14/07, Dylan Beaudette <dylan.beaudette@gmail.com> wrote:

On Saturday 13 October 2007, Carlos "Guâno" Grohmann wrote:
> I think I already asked this, but without much success, so here is:
> can I use v.to.db to get the azimuth of a line? I am thinking in
> lineament analysis, so it's a simple line, just two end vertices.
>
> thanks
>
> Carlos

Can you calculate it from the end points ?

Like this:

http://casoilresource.lawr.ucdavis.edu/drupal/node/468

.... except that the calculation I am doing is in R. atan2() should exist in
the c library, so adding it to GRASS should be a small effort.

Dylan

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

--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc - Doctorate Student at IGc-USP - Brazil
Linux User #89721 - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can't stop the signal.

(attachments)

rose.jpg

Carlos wrote:

This is almost what I need. I need the results to be in range 0-360,
from North. So I can get a rose diagram, with petals weighted
according to azimuth frequency or to azimuth lenght, like the
attachment.

convert CCW-from-east to CW-from-north with 90-theta

Hamish

      ____________________________________________________________________________________
Catch up on fall's hot new shows on Yahoo! TV. Watch previews, get listings, and more!
http://tv.yahoo.com/collections/3658

On 10/14/07, Carlos Guâno Grohmann <carlos.grohmann@gmail.com> wrote:

This is almost what I need. I need the results to be in range 0-360,
from North. So I can get a rose diagram, with petals weighted
according to azimuth frequency or to azimuth lenght, like the
attachment.

Here is a handy formula to get from mathematical "M" angles to
geodetic "G" angles. Mathematical angles are where 0 is the X axis and
the increase counter-clockwise, and geodetic angles begin on the Y
axis and increase clockwise. The formula is in degrees. The formula is
handy because it does it in one step without if/then conditionals.

   G = (450-M) - int( (450-M) / 360) * 360

HTH,
Rich

--
Richard Greenwood
richard.greenwood@gmail.com
www.greenwoodmap.com

Carlos "Guâno" Grohmann wrote:

This is almost what I need. I need the results to be in range 0-360,
from North. So I can get a rose diagram, with petals weighted
according to azimuth frequency or to azimuth lenght, like the
attachment.

I've just remember PROJ.4's geod [1]. Example:

$ echo "50N 19E 51N 20E" | geod -I +ellps=WGS84 +units=m
32d8'43.417" -147d4'58.6" 131935.963

The 1st 2 numbers are azimuth from the 1st to 2nd point and
back, respectively, 3rd is the distance between them.

[1]http://proj.maptools.org/man_geod.html

Maciek

OK, I am trying to get these thing working with db.execute.

although these work:

echo "UPDATE Lineam_isobase SET dx=end_x-start_x" | db.execute
echo "UPDATE Lineam_isobase SET dy=end_y-start_y" | db.execute

this doesn't:

echo "UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)" | db.execute

DBMI-DBF driver error:
SQL parser error:
in statement:
UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)

Error in db_execute_immediate()

ERROR: Error while executing: 'UPDATE Lineam_isobase SET
       ang_rad=atan2(dx,dy)
       '

thoughts?

cheers

Carlos

On 10/18/07, Maciej Sieczka <tutey@o2.pl> wrote:

Carlos "Guâno" Grohmann wrote:
> This is almost what I need. I need the results to be in range 0-360,
> from North. So I can get a rose diagram, with petals weighted
> according to azimuth frequency or to azimuth lenght, like the
> attachment.

I've just remember PROJ.4's geod [1]. Example:

$ echo "50N 19E 51N 20E" | geod -I +ellps=WGS84 +units=m
32d8'43.417" -147d4'58.6" 131935.963

The 1st 2 numbers are azimuth from the 1st to 2nd point and
back, respectively, 3rd is the distance between them.

[1]http://proj.maptools.org/man_geod.html

Maciek

--
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano
  Visiting Researcher at Kingston University London - UK
  Geologist M.Sc - Doctorate Student at IGc-USP - Brazil
Linux User #89721 - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can't stop the signal.

On 18/10/07 13:17, Carlos "Guâno" Grohmann wrote:

OK, I am trying to get these thing working with db.execute.

although these work:

echo "UPDATE Lineam_isobase SET dx=end_x-start_x" | db.execute
echo "UPDATE Lineam_isobase SET dy=end_y-start_y" | db.execute

this doesn't:

echo "UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)" | db.execute

DBMI-DBF driver error:
SQL parser error:
in statement:
UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)

Error in db_execute_immediate()

ERROR: Error while executing: 'UPDATE Lineam_isobase SET
       ang_rad=atan2(dx,dy)
       '

thoughts?

Which database backend are you using ?

Try running after setting 'g.gisenv set=DEBUG=3'.

Moritz

Hi,

2007/10/18, Carlos Guâno Grohmann <carlos.grohmann@gmail.com>:

OK, I am trying to get these thing working with db.execute.

although these work:
> echo "UPDATE Lineam_isobase SET dx=end_x-start_x" | db.execute
> echo "UPDATE Lineam_isobase SET dy=end_y-start_y" | db.execute

this doesn't:

> echo "UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)" | db.execute
DBMI-DBF driver error:
SQL parser error:
in statement:
UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)

Error in db_execute_immediate()

ERROR: Error while executing: 'UPDATE Lineam_isobase SET
       ang_rad=atan2(dx,dy)
       '

Use instead of DBF e.g. pg driver, atan2() is not supported by DBF driver.

Martin

--
Martin Landa <landa.martin@gmail.com> * http://gama.fsv.cvut.cz/~landa *

On 18/10/07 14:41, Moritz Lennert wrote:

On 18/10/07 13:17, Carlos "Guâno" Grohmann wrote:

OK, I am trying to get these thing working with db.execute.

although these work:

echo "UPDATE Lineam_isobase SET dx=end_x-start_x" | db.execute
echo "UPDATE Lineam_isobase SET dy=end_y-start_y" | db.execute

this doesn't:

echo "UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)" | db.execute

DBMI-DBF driver error:
SQL parser error:
in statement:
UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)

Error in db_execute_immediate()

ERROR: Error while executing: 'UPDATE Lineam_isobase SET
       ang_rad=atan2(dx,dy)
       '

thoughts?

Which database backend are you using ?

Sorry, just saw that the information is above (DBMI-DBF): don't think that the dbf driver supports atan2(). Try with postgresql.

Moritz

Carlos wrote:

> this doesn't:
>
> > echo "UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)" | db.execute
> DBMI-DBF driver error:
> SQL parser error:
> in statement:
> UPDATE Lineam_isobase SET ang_rad=atan2(dx,dy)
>
> Error in db_execute_immediate()
>
> ERROR: Error while executing: 'UPDATE Lineam_isobase SET
> ang_rad=atan2(dx,dy)

Martin wrote:

Use instead of DBF e.g. pg driver, atan2() is not supported by DBF driver.

could you get the values of dx,dy to the shell with (v.)db.select then use awk
to do the math and send the result to db.execute?

Other DBs (SQLite, MySQL, Postgres,..) should support it directly.

Hamish

__________________________________________________
Do You Yahoo!?
Tired of spam? Yahoo! Mail has the best spam protection around
http://mail.yahoo.com

Hello all.
I also needed to do some lineament orientation analysis and to do so I
modified v.to.db [1]. Now it supports calculating line azimuths as CW
direction from line start point to line endpoint.

Usage example:
v.to.db map=lineaments type=line option=azimuth units=degrees
columns=orientation

svn up Your develbranch6 and test it :slight_smile:

Maris.

1. http://trac.osgeo.org/grass/changeset/36528

Hi,

2009/3/30 Maris Nartiss <maris.gis@gmail.com>:

I also needed to do some lineament orientation analysis and to do so I
modified v.to.db [1]. Now it supports calculating line azimuths as CW
direction from line start point to line endpoint.

Usage example:
v.to.db map=lineaments type=line option=azimuth units=degrees
columns=orientation

svn up Your develbranch6 and test it :slight_smile:

any reason why not to commit also to trunk?

M.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Yes.
I have no space to checkout GRASS 7 and thus can't test those changes
under GRASS 7. Still I hope to get my new Dell up and running after
four months of trying to get away from memory problems. Then I will
have enough space to work on more than one branch...

Maris.

2009/3/30, Martin Landa <landa.martin@gmail.com>:

Hi,

any reason why not to commit also to trunk?

M.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Hi,

2009/3/30 Maris Nartiss <maris.gis@gmail.com>:

I have no space to checkout GRASS 7 and thus can't test those changes
under GRASS 7. Still I hope to get my new Dell up and running after
four months of trying to get away from memory problems. Then I will
have enough space to work on more than one branch...

are you tracking which patches will go to trunk or I can commit this
path to trunk?

M.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

Maris,

I have merged it into GRASS 7.

Markus

On Mon, Mar 30, 2009 at 3:30 PM, Maris Nartiss <maris.gis@gmail.com> wrote:

Yes.
I have no space to checkout GRASS 7 and thus can't test those changes
under GRASS 7. Still I hope to get my new Dell up and running after
four months of trying to get away from memory problems. Then I will
have enough space to work on more than one branch...

Maris.

2009/3/30, Martin Landa <landa.martin@gmail.com>:

Hi,

any reason why not to commit also to trunk?

M.

--
Martin Landa <landa.martin gmail.com> * http://gama.fsv.cvut.cz/~landa

_______________________________________________
grass-user mailing list
grass-user@lists.osgeo.org
http://lists.osgeo.org/mailman/listinfo/grass-user

Hello.

I did a full up of my develbranch but couldn't use the azimuth option:

> v.to.db map=lineamentos type=line option=azimuth units=degrees
columns=azimute

ERROR: value <azimuth> out of range for parameter <option>
       Legal range:
cat,area,compact,fd,perimeter,length,count,coor,start,end,sides,query,slope,sinuous

ERROR: value <degrees> out of range for parameter <units>
       Legal range: mi,miles,f,feet,me,meters,k,kilometers,a,acres,h,hectares

cheers

carlos

On Mon, Mar 30, 2009 at 09:36, Maris Nartiss <maris.gis@gmail.com> wrote:

Hello all.
I also needed to do some lineament orientation analysis and to do so I
modified v.to.db [1]. Now it supports calculating line azimuths as CW
direction from line start point to line endpoint.

Usage example:
v.to.db map=lineaments type=line option=azimuth units=degrees
columns=orientation

svn up Your develbranch6 and test it :slight_smile:

Maris.

1. http://trac.osgeo.org/grass/changeset/36528

--
Carlos Henrique Grohmann - Geologist D.Sc.
a.k.a. Guano - Linux User #89721
ResearcherID: A-9030-2008
carlos dot grohmann at gmail dot com
http://www.igc.usp.br/pessoais/guano/
_________________
"Good morning, doctors. I have taken the liberty of removing Windows
95 from my hard drive."
--The winning entry in a "What were HAL's first words" contest judged
by 2001: A SPACE ODYSSEY creator Arthur C. Clarke

Can’t stop the signal.

Hello Carlos,
svn up
cd vector/v.to.db
make clean && make

It's in develbranch_6 r36528 [1]

Maris.

1. http://trac.osgeo.org/grass/changeset/36528