Skip to content

Instantly share code, notes, and snippets.

@stepankuzmin
Created June 26, 2015 13:14
Show Gist options
  • Save stepankuzmin/fca34a82eb71b813dc16 to your computer and use it in GitHub Desktop.
Save stepankuzmin/fca34a82eb71b813dc16 to your computer and use it in GitHub Desktop.
PostGIS polygon inversion function — allows to invert polygon with 900913 SRID
create function st_invert(geometry) returns setof geometry as
'SELECT st_difference(st_geomfromtext(''POLYGON((-20037508.3427892 147730758.194568,
20037508.3427892 147730758.194568,
20037508.3427892 -147730762.669922,
-20037508.3427892 -147730762.669922,
-20037508.3427892 147730758.194568))'', 900913), $1)'
language sql;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment