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.
For the above sample linestrings,
ST_EndPoint() return the start and end points (
Ys) of the same. Based on these
Ys (long/lat), how do I estimate the direction of travel of these linestrings?
Assuming that I have my area of interest in the northern hemisphere. Following diagram may "represent" the "direction of travel" (from north to south).