Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
Create great circles in postgis / cartodb.
http://gis.stackexchange.com/questions/84443/what-is-this-postgis-query-doing-to-show-great-circle-connections/84444#84444
The examples given, and the previous answer all depend on taking the line into a planar projection and then segmentizing. As of PostGIS 2.1 (which I think CartoDB is on) you can do a general-purpose job of it using ST_Segmentize(geography), so like this:
SELECT
ST_Segmentize(
ST_MakeLine(
ST_SetSRID(ST_MakePoint(-71.060316, 48.432044),4326),
pt
)::geography
, 10000
)::geometry
FROM mytable;
In words,
make a central point in SRS 4326
make a line between that point and each point in the table
convert that line into the geography type
segmentize in geography space (along the great circle route)
convert that detailed geography back into geometry
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.