Skip to content

Instantly share code, notes, and snippets.

@mhkeller
Created June 5, 2014 22:09
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mhkeller/e6a2790b841331dd2f84 to your computer and use it in GitHub Desktop.
Save mhkeller/e6a2790b841331dd2f84 to your computer and use it in GitHub Desktop.
Great arcs in CartoDB PostGIS
SELECT ST_Transform(
ST_Segmentize(
ST_MakeLine(
ST_Transform(CDB_LatLng(source_lat, source_lng), 953027),
ST_Transform(ST_PointOnSurface(CDB_LatLng(target_lat, target_lng)),953027)
), 100000
), 3857) as the_geom_webmercator
FROM table
UPDATE my_table
SET the_geom =
ST_Transform(
ST_Segmentize(
ST_MakeLine(
ST_Transform(my_table.the_geom, 953027),
ST_Transform(CDB_LatLng(48.432044, -71.060316), 953027)
),
100000
),
4326
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment