Created
June 27, 2015 22:41
-
-
Save alexanno/1d4c6722b5d7644dd122 to your computer and use it in GitHub Desktop.
Create great circles in postgis / cartodb.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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