Skip to content

Instantly share code, notes, and snippets.

@andrewcottam
Last active November 26, 2019 19:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save andrewcottam/b2d6378852496e4a1281f67892887a56 to your computer and use it in GitHub Desktop.
Save andrewcottam/b2d6378852496e4a1281f67892887a56 to your computer and use it in GitHub Desktop.
Split a polygon that spans the dateline in PostGIS
SELECT ST_WrapX(ST_Split((SELECT ST_ShiftLongitude(ST_Polygon('LINESTRING(179 18, -179 18, -179 17, 179 17, 179 18)'::geometry, 4326))),(SELECT ST_ShiftLongitude(ST_GeogFromText('LINESTRING(180 90, 180 -90)')::geometry))),180,-360);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment