[postgis-users] Removing holes from polygons

Paragon Corporation lr at pcorp.us
Tue Nov 3 23:50:55 PST 2009


AkHil,

It could be you don't have holes at all and what you have are invalid
multipolygons that intersect each other.  On screen they may appear to be
holes because one polygon is within another.

One way to turn the overlapping/inner polygons into holes is to do a
ST_BuildArea on them.
http://www.postgis.org/documentation/manual-svn/ST_BuildArea.html

So 
1) Take your original set of data and do a

SELECT gid, ST_BuildArea(the_geom) As the_geom
INTO newtable
FROM origtable

2) Then reapply what we mentioned ST_ExteriorRing to get the holes out.

Hope that helps,
Regina 

-----Original Message-----
From: postgis-users-bounces at postgis.refractions.net
[mailto:postgis-users-bounces at postgis.refractions.net] On Behalf Of Akhil
Jaggarwal
Sent: Tuesday, November 03, 2009 4:54 PM
To: postgis-users at postgis.refractions.net
Subject: [postgis-users] Removing holes from polygons

Thanks Paragon Corp and strk.

I've tried both the queries but I'm getting back the same multipolygon which
I had to explode to do subsetting.

The exploded table had 416 geometries (holes + polygons) as compared to the
original table with multipolygons which has 234 geometries.

I've also tried union to get the bigger of the contained geometries but that
doesn't seem to work either.


Regards
AKhil
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users






More information about the postgis-users mailing list