I have a table full of linestrings in PostGIS. I would like to know the degrees clockwise from north of the starting point of the linestring and also of the end point.

I was thinking that maybe creating a circle with both points could help to get this two values (example: X=32º, Y=209º) but i have no clue how to achieve this....

enter image description here


1 Answer 1


St_Azimuth may be helpful. The help page shows how to generate the degrees from north. http://postgis.net/docs/ST_Azimuth.html

  • ST_Azimuth seems to work between separate geometries (points only), instead of along the vertices of a linestring. Or is there another way to use it?
    – Simbamangu
    Nov 16, 2013 at 15:50
  • right but the first point of the linestring can be obtained with the st_startpoint function and the endpoint with the st_endpoint.
    – Egidi
    Nov 16, 2013 at 19:10
  • I will get the st_centroid of the poliline and then use that point in st_azimuth with the point obtained with st_startpoint and then again with st_endpoint
    – Egidi
    Nov 16, 2013 at 19:15

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.