Gis Tricks

Postgis equivalent of erase in arcgis

Postgis equivalent of erase in arcgis

Recently I needed an ArcGIS equivalent of the erase function. This turns out to be hard to find. There are hints in the mailinglist, but no complete worked out example.

 

As Bborie points out it is quite simple. But I can image that if you are not that experienced you would like to have an example. I know I do!

The trick is that the polygons with which you erase have to be union together.

blade_polygons

Blade polygons

[SQL]
DROP TABLE IF EXISTS blade_polygon_union;
CREATE TABLE blade_polygon_union AS
SELECT ST_Union(geom) as geom
FROM blade_polygon;
[/SQL]

blade_polygons_union

Blade polygons unioned

Now we can use them to erase from the polygons

polygons_before

Polygons original

[SQL]
DROP TABLE IF EXISTS polygons_erased;
CREATE TABLE polygons_erased AS
SELECT ST_Difference(a.geom, b.geom) as geom, *
FROM blade_polygon_union as b, polygons as a
WHERE a.geom && b.geom;

[/SQL]

And the result:

polygons_after

Result after erase

Hope this helps, sadly this is not the quickest of procedures, especially on large areas. If someone has a quicker solution in which the union is not required I’d be happy to hear it.

2 thoughts on “Postgis equivalent of erase in arcgis

Leave a Reply

Your email address will not be published. Required fields are marked *

1 × 2 =