# Creating Great Circle Line from Two Points

I am trying to create a great circle line in order to ascertain if one was looking 'straight-out' from the end of a pier what country/place they would be viewing. I have the below PostGIS code written:

``````-- assume two points, calculate the angle, then extend it.
-- point 1 = -33.6307920509579, 115.338797474435
-- point 2 = -33.6290969607648, 115.338316140276
SELECT
ST_Segmentize( -- break it up into segments so it looks better when re-projecting for display
ST_MakeLine(
ST_SetSRID(ST_Point(115.338797474435, -33.6307920509579), 4326) -- starting point (ST_MakeLine expects projected coordinates)
,ST_Transform(
ST_Project( -- find a point a long way away to use  as the second point in the line
ST_Point(115.338797474435, -33.6307920509579)::geography -- starting point again
,20000000 -- 1/2 circumference of earth at the equator (should get us far enough)
,ST_Azimuth(ST_Point(115.338797474435, -33.6307920509579)::geography, ST_Point(115.338316140276, -33.6290969607648)::geography) -- angle between my two points
)::geometry,
4326)
)::geography
,20000 -- break it into segments of 20km
);
``````

When I create the linestring and open it in QGIS I get a great circle line but the angle is not correct (as shown below). What am I missing?

• I'm not sure if the result is wrong- a great circle line on OSM that uses Web mercator - `EPSG:3857` would result in a line like this: 4.bp.blogspot.com/-nJyLLfJXsQ8/Wj-FUthJhyI/AAAAAAAAECQ/… - if you just connect start- and endpoint, you get a straight line following a completely different path, but still the correct destination- see the second line on the linked image. Nov 21, 2021 at 10:26
• As you see, the direction at the start point is completely different, still the result for your question is the same: the country of the line's wnd point. So make sure if this is the case in your case. Test it by exporting the line to a kml file and open it in Google Earth: it is a very intuitive way to see where a great circle line passes through. Nov 21, 2021 at 10:30