Estimating direction of travel of road line segment based on long/lat in PostGIS? The 2019 Stack Overflow Developer Survey Results Are In Announcing the arrival of Valued Associate #679: Cesar Manara Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Finding compass direction between two distant GPS points?Identify the direction of traveling road segmentpostgis create geom from lat longPostGIS select by lat/long bounding boxIdentify the direction of traveling road segmentpostgis update geom from lat and longHow can I measure(length) line of segment in postgis?Postgis query to convert UTM to Lat longOS Terrain 50 into Postgresql/PostGIS for lat/long analysisDijkstra's Algorithm direction issueCalculate values for all lat/long in another table based on where calculationEstimating road width in PostGIS?

What information about me do stores get via my credit card?

Is it ethical to upload a automatically generated paper to a non peer-reviewed site as part of a larger research?

Take groceries in checked luggage

How are presidential pardons supposed to be used?

Make it rain characters

How do you keep chess fun when your opponent constantly beats you?

What do you call a plan that's an alternative plan in case your initial plan fails?

Is every episode of "Where are my Pants?" identical?

Why's the Graph of this Function so Wonky?

Derivation tree not rendering

Why can't wing-mounted spoilers be used to steepen approaches?

Was credit for the black hole image misattributed?

How does ice melt when immersed in water?

Can a novice safely splice in wire to lengthen 5V charging cable?

How to politely respond to generic emails requesting a PhD/job in my lab? Without wasting too much time

How to test the equality of two Pearson correlation coefficients computed from the same sample?

What's the point in a preamp?

Arduino Pro Micro - switch off LEDs

How can I protect witches in combat who wear limited clothing?

Can undead you have reanimated wait inside a portable hole?

Are my PIs rude or am I just being too sensitive?

How did the audience guess the pentatonic scale in Bobby McFerrin's presentation?

Can withdrawing asylum be illegal?

Why does the Event Horizon Telescope (EHT) not include telescopes from Africa, Asia or Australia?



Estimating direction of travel of road line segment based on long/lat in PostGIS?



The 2019 Stack Overflow Developer Survey Results Are In
Announcing the arrival of Valued Associate #679: Cesar Manara
Planned maintenance scheduled April 17/18, 2019 at 00:00UTC (8:00pm US/Eastern)Finding compass direction between two distant GPS points?Identify the direction of traveling road segmentpostgis create geom from lat longPostGIS select by lat/long bounding boxIdentify the direction of traveling road segmentpostgis update geom from lat and longHow can I measure(length) line of segment in postgis?Postgis query to convert UTM to Lat longOS Terrain 50 into Postgresql/PostGIS for lat/long analysisDijkstra's Algorithm direction issueCalculate values for all lat/long in another table based on where calculationEstimating road width in PostGIS?



.everyoneloves__top-leaderboard:empty,.everyoneloves__mid-leaderboard:empty,.everyoneloves__bot-mid-leaderboard:empty margin-bottom:0;








0















Well, this seems pretty simple but haven't been answered cleanly in previous relevant questions for example:




  • Identify the direction of traveling road segment and

  • Finding compass direction between two distant GPS points?

I have a large dataset of road network (multi-linestrings) of an area of interest converted to linestrings using ST_Dump(). For each linestring, I would like to estimate "the direction of travel" (north to south, east to west and vice versa) based on extracted X,Ys. Two sample linestrings are shown below.



linestring 1



linestring 2



For the above sample linestrings, ST_StartPoint() and ST_EndPoint() return the start and end points (Xs, Ys) of the same. Based on these X,Ys (long/lat), how do I estimate the direction of travel of these linestrings?



UPDATE



Assuming that I have my area of interest in the northern hemisphere. Following diagram may "represent" the "direction of travel" (from north to south).



"direction of travel" in the first case










share|improve this question






























    0















    Well, this seems pretty simple but haven't been answered cleanly in previous relevant questions for example:




    • Identify the direction of traveling road segment and

    • Finding compass direction between two distant GPS points?

    I have a large dataset of road network (multi-linestrings) of an area of interest converted to linestrings using ST_Dump(). For each linestring, I would like to estimate "the direction of travel" (north to south, east to west and vice versa) based on extracted X,Ys. Two sample linestrings are shown below.



    linestring 1



    linestring 2



    For the above sample linestrings, ST_StartPoint() and ST_EndPoint() return the start and end points (Xs, Ys) of the same. Based on these X,Ys (long/lat), how do I estimate the direction of travel of these linestrings?



    UPDATE



    Assuming that I have my area of interest in the northern hemisphere. Following diagram may "represent" the "direction of travel" (from north to south).



    "direction of travel" in the first case










    share|improve this question


























      0












      0








      0








      Well, this seems pretty simple but haven't been answered cleanly in previous relevant questions for example:




      • Identify the direction of traveling road segment and

      • Finding compass direction between two distant GPS points?

      I have a large dataset of road network (multi-linestrings) of an area of interest converted to linestrings using ST_Dump(). For each linestring, I would like to estimate "the direction of travel" (north to south, east to west and vice versa) based on extracted X,Ys. Two sample linestrings are shown below.



      linestring 1



      linestring 2



      For the above sample linestrings, ST_StartPoint() and ST_EndPoint() return the start and end points (Xs, Ys) of the same. Based on these X,Ys (long/lat), how do I estimate the direction of travel of these linestrings?



      UPDATE



      Assuming that I have my area of interest in the northern hemisphere. Following diagram may "represent" the "direction of travel" (from north to south).



      "direction of travel" in the first case










      share|improve this question
















      Well, this seems pretty simple but haven't been answered cleanly in previous relevant questions for example:




      • Identify the direction of traveling road segment and

      • Finding compass direction between two distant GPS points?

      I have a large dataset of road network (multi-linestrings) of an area of interest converted to linestrings using ST_Dump(). For each linestring, I would like to estimate "the direction of travel" (north to south, east to west and vice versa) based on extracted X,Ys. Two sample linestrings are shown below.



      linestring 1



      linestring 2



      For the above sample linestrings, ST_StartPoint() and ST_EndPoint() return the start and end points (Xs, Ys) of the same. Based on these X,Ys (long/lat), how do I estimate the direction of travel of these linestrings?



      UPDATE



      Assuming that I have my area of interest in the northern hemisphere. Following diagram may "represent" the "direction of travel" (from north to south).



      "direction of travel" in the first case







      postgis postgresql






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Jan 2 '18 at 12:40







      Jibran Khan

















      asked Jan 2 '18 at 10:26









      Jibran KhanJibran Khan

      495415




      495415




















          1 Answer
          1






          active

          oldest

          votes


















          0














          You are looking for ST_Azimuth



          http://postgis.net/docs/manual-2.4/ST_Azimuth.html






          share|improve this answer























          • Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

            – Jibran Khan
            Jan 2 '18 at 11:23











          • As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

            – Jibran Khan
            Jan 2 '18 at 11:24












          • I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

            – Nicklas Avén
            Jan 2 '18 at 12:21











          • My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

            – Jibran Khan
            Jan 2 '18 at 12:34











          • I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

            – Nicklas Avén
            Jan 3 '18 at 12:50











          Your Answer








          StackExchange.ready(function()
          var channelOptions =
          tags: "".split(" "),
          id: "79"
          ;
          initTagRenderer("".split(" "), "".split(" "), channelOptions);

          StackExchange.using("externalEditor", function()
          // Have to fire editor after snippets, if snippets enabled
          if (StackExchange.settings.snippets.snippetsEnabled)
          StackExchange.using("snippets", function()
          createEditor();
          );

          else
          createEditor();

          );

          function createEditor()
          StackExchange.prepareEditor(
          heartbeatType: 'answer',
          autoActivateHeartbeat: false,
          convertImagesToLinks: false,
          noModals: true,
          showLowRepImageUploadWarning: true,
          reputationToPostImages: null,
          bindNavPrevention: true,
          postfix: "",
          imageUploader:
          brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
          contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
          allowUrls: true
          ,
          onDemand: true,
          discardSelector: ".discard-answer"
          ,immediatelyShowMarkdownHelp:true
          );



          );













          draft saved

          draft discarded


















          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f266690%2festimating-direction-of-travel-of-road-line-segment-based-on-long-lat-in-postgis%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown

























          1 Answer
          1






          active

          oldest

          votes








          1 Answer
          1






          active

          oldest

          votes









          active

          oldest

          votes






          active

          oldest

          votes









          0














          You are looking for ST_Azimuth



          http://postgis.net/docs/manual-2.4/ST_Azimuth.html






          share|improve this answer























          • Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

            – Jibran Khan
            Jan 2 '18 at 11:23











          • As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

            – Jibran Khan
            Jan 2 '18 at 11:24












          • I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

            – Nicklas Avén
            Jan 2 '18 at 12:21











          • My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

            – Jibran Khan
            Jan 2 '18 at 12:34











          • I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

            – Nicklas Avén
            Jan 3 '18 at 12:50















          0














          You are looking for ST_Azimuth



          http://postgis.net/docs/manual-2.4/ST_Azimuth.html






          share|improve this answer























          • Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

            – Jibran Khan
            Jan 2 '18 at 11:23











          • As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

            – Jibran Khan
            Jan 2 '18 at 11:24












          • I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

            – Nicklas Avén
            Jan 2 '18 at 12:21











          • My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

            – Jibran Khan
            Jan 2 '18 at 12:34











          • I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

            – Nicklas Avén
            Jan 3 '18 at 12:50













          0












          0








          0







          You are looking for ST_Azimuth



          http://postgis.net/docs/manual-2.4/ST_Azimuth.html






          share|improve this answer













          You are looking for ST_Azimuth



          http://postgis.net/docs/manual-2.4/ST_Azimuth.html







          share|improve this answer












          share|improve this answer



          share|improve this answer










          answered Jan 2 '18 at 11:01









          Nicklas AvénNicklas Avén

          11.7k12841




          11.7k12841












          • Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

            – Jibran Khan
            Jan 2 '18 at 11:23











          • As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

            – Jibran Khan
            Jan 2 '18 at 11:24












          • I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

            – Nicklas Avén
            Jan 2 '18 at 12:21











          • My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

            – Jibran Khan
            Jan 2 '18 at 12:34











          • I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

            – Nicklas Avén
            Jan 3 '18 at 12:50

















          • Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

            – Jibran Khan
            Jan 2 '18 at 11:23











          • As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

            – Jibran Khan
            Jan 2 '18 at 11:24












          • I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

            – Nicklas Avén
            Jan 2 '18 at 12:21











          • My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

            – Jibran Khan
            Jan 2 '18 at 12:34











          • I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

            – Nicklas Avén
            Jan 3 '18 at 12:50
















          Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

          – Jibran Khan
          Jan 2 '18 at 11:23





          Thank you for your words =) Please correct me if I am terribly wrong. ST_Azimuth(ST_StartPoint(geom), ST_EndPoint(geom)) estimates the north-based azimuth (direction) of linestring. While, I am trying to estimate whether linestring is north-to-south and vice versa etc. based on latitudes/longitudes differences. Is there something wrong with this approach?

          – Jibran Khan
          Jan 2 '18 at 11:23













          As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

          – Jibran Khan
          Jan 2 '18 at 11:24






          As suggested here: gis.stackexchange.com/questions/75554/… linestring's "direction of travel" can be determined by the order of coordinates as well.

          – Jibran Khan
          Jan 2 '18 at 11:24














          I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

          – Nicklas Avén
          Jan 2 '18 at 12:21





          I might misunderstand what you want. As I understand it toy want the direction of theline from start point to end point. That you get from ST_Azimuth, both for geometry and geography type. From that value you can tell if the direction is north or south or east or west. You can have a table with ranges defining the directions and join the answer against that if you want it expressed in text. A table with fields for min radians, max radians and text representation. Or is there a "direction of travel" based on something else than start point and end point that you are searching?

          – Nicklas Avén
          Jan 2 '18 at 12:21













          My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

          – Jibran Khan
          Jan 2 '18 at 12:34





          My bad! Probably, I was unable to provide better explanations. I am aware that ST_Azimuth() would return me line segment's direction in degrees or radians. Basically, this is not what I am looking for. I wanted to identify whether line segment is towards north-south (in the first case, for example) or not based on long/lat differences i.e., what is the "direction of travel" based on order/difference of coordinates of linestring. I will add one more figure to help clarify "direction of travel".

          – Jibran Khan
          Jan 2 '18 at 12:34













          I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

          – Nicklas Avén
          Jan 3 '18 at 12:50





          I am afraid I still miss something. From your last example, you will get approx pi as azimuth, which tells you that the direction between the 2 points is towards south. Isn't that want you want to find out?

          – Nicklas Avén
          Jan 3 '18 at 12:50

















          draft saved

          draft discarded
















































          Thanks for contributing an answer to Geographic Information Systems Stack Exchange!


          • Please be sure to answer the question. Provide details and share your research!

          But avoid


          • Asking for help, clarification, or responding to other answers.

          • Making statements based on opinion; back them up with references or personal experience.

          To learn more, see our tips on writing great answers.




          draft saved


          draft discarded














          StackExchange.ready(
          function ()
          StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fgis.stackexchange.com%2fquestions%2f266690%2festimating-direction-of-travel-of-road-line-segment-based-on-long-lat-in-postgis%23new-answer', 'question_page');

          );

          Post as a guest















          Required, but never shown





















































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown

































          Required, but never shown














          Required, but never shown












          Required, but never shown







          Required, but never shown







          Popular posts from this blog

          រឿង រ៉ូមេអូ និង ហ្ស៊ុយលីយេ សង្ខេបរឿង តួអង្គ បញ្ជីណែនាំ

          QGIS export composer to PDF scale the map [closed] Planned maintenance scheduled April 23, 2019 at 23:30 UTC (7:30pm US/Eastern) Announcing the arrival of Valued Associate #679: Cesar Manara Unicorn Meta Zoo #1: Why another podcast?Print Composer QGIS 2.6, how to export image?QGIS 2.8.1 print composer won't export all OpenCycleMap base layer tilesSave Print/Map QGIS composer view as PNG/PDF using Python (without changing anything in visible layout)?Export QGIS Print Composer PDF with searchable text labelsQGIS Print Composer does not change from landscape to portrait orientation?How can I avoid map size and scale changes in print composer?Fuzzy PDF export in QGIS running on macSierra OSExport the legend into its 100% size using Print ComposerScale-dependent rendering in QGIS PDF output

          PDF-ში გადმოწერა სანავიგაციო მენიუproject page