[GRASSLIST:7830] Re: azimuth of a line

Carlos Guâno Grohmann carlos.grohmann at gmail.com
Mon Aug 8 23:01:13 EDT 2005


I have a C program that read a ASCII vector from GRASS_5 and
calculates the length and azimuth of the lines. I will have to use it,
then. It's just that I think I saw somewhere that v.to.db could do it
(it does for length..).

Carlos



On 8/8/05, David Finlayson <david.p.finlayson at gmail.com> wrote:
> The script url was wrong, here is the correct url:
> 
> http://students.washington.edu/dfinlays/scripts/2005/cogop.py
> 
> David
> 
> On 8/8/05, David Finlayson <david.p.finlayson at gmail.com> wrote:
> > I'm not sure exactly what you need. But this might help.
> >
> > 1) Convert the nodes of your coverage to points using v.to.points
> > (format=point option)
> >
> > 2) Dump the points as an ascii text stream using v.to.ascii and pipe
> > the results into a
> > script that calculates the azimuth.
> >
> > I have written a small python utility that calculates the distance and
> > azimuth along a list of points:
> >
> > http://students.washington.edu/dfinlays/scripts/cogop.py
> >
> > Here is an example of how it can be used. I have a polygon called
> > trimpoly. I convert it to a list of points using v.to.points:
> >
> > GRASS 6.1.cvs (UTM10_NAD83): > v.to.points -v input=trimpoly output=trimpolypts
> > Building topology ...
> > 20 primitives registered
> > Building areas:  100%
> > 0 areas built
> > 0 isles built
> > Attaching islands:
> > Attaching centroids:  100%
> > Topology was built.
> > Number of nodes     :   19
> > Number of primitives:   20
> > Number of points    :   20
> > Number of lines     :   0
> > Number of boundaries:   0
> > Number of centroids :   0
> > Number of areas     :   0
> > Number of isles     :   0
> > 20 points written to output map
> >
> > Now I can dump this point file as ascii text:
> >
> > > v.out.ascii input=trimpolypts
> > 536022.25|5332267.25|-1
> > 536029.98|5332292.26|-1
> > 536041|5332314.36|-1
> > 536066.78|5332355.57|-1
> > 536081.01|5332349.24|-1
> > 536098.13|5332341.62|-1
> > ...
> >
> > We can get rid of the pipe characters and replace them with tabs with
> > sed and then
> > pipe the result to my cogop.py script like this:
> >
> > > v.out.ascii input=trimpolypts | sed 's/|/\t/g' | cogop -a
> > 0.0  536022.25 5332267.25 -1
> > 26.18 17.18 536029.98 5332292.26 -1
> > 24.7 26.5 536041 5332314.36 -1
> > 48.61 32.03 536066.78 5332355.57 -1
> > 15.57 113.98 536081.01 5332349.24 -1
> > 18.74 113.99 536098.13 5332341.62 -1
> >
> > The first column is the distance between points, the second column is
> > the azimuth from point 1 to point 2, finally, the script appends the
> > input fields. cogop has a few other options like setting a benchmark
> > and calculating cumulative distance, etc. Of course the order of the
> > points is important.
> >
> > Hope that gives you some ideas,
> >
> > David
> >
> >
> > On 8/8/05, Carlos Guâno Grohmann <carlos.grohmann at gmail.com> wrote:
> > > I was wondering if v.to.db could have a "azimuth" option, to calculate
> > > the azimuth of line segments, based on the end vertices coordinates.
> > >
> > > Carlos
> > > --
> > > +-----------------------------------------------------------+
> > >               Carlos Henrique Grohmann - Guano
> > >   Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
> > > Linux User #89721  - carlos dot grohmann at gmail dot com
> > > +-----------------------------------------------------------+
> > >
> > >
> >
> >
> > --
> > David Finlayson
> > Marine Geology & Geophysics
> > School of Oceanography
> > Box 357940
> > University of Washington
> > Seattle, WA  98195-7940
> > USA
> >
> > Office: Marine Sciences Building, Room 112
> > Phone: (206) 616-9407
> > Web: http://students.washington.edu/dfinlays
> >
> 
> 
> --
> David Finlayson
> Marine Geology & Geophysics
> School of Oceanography
> Box 357940
> University of Washington
> Seattle, WA  98195-7940
> USA
> 
> Office: Marine Sciences Building, Room 112
> Phone: (206) 616-9407
> Web: http://students.washington.edu/dfinlays
> 


-- 
+-----------------------------------------------------------+
              Carlos Henrique Grohmann - Guano   
  Geologist M.Sc  - Doctorate Student at IGc-USP - Brazil
Linux User #89721  - carlos dot grohmann at gmail dot com
+-----------------------------------------------------------+




More information about the grass-user mailing list