Removing holes from polygons

View: New views
3 Messages — Rating Filter:   Alert me  

Removing holes from polygons

by Akhil Jaggarwal-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I've a table T1 containing geometry of Regions (Arctic, Atlantic
Ocean) exploded from mulipolygons into polygons which have holes in it
(islands).

My another table T1_subset consists of a geometry dataset which is
actually a subset of the the regions found in Table T1. Turns out that
the subset query to find out regions in Table T2 contained the Region
Polygons takes a lot of time because of the holes contained in the
polygons in T1.

Any tips or hints on a query which removes all the inner holes from a
polygon and returns and keeps the geometry of the largest one intact?

-Akhil
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: Removing holes from polygons

by strk-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Tue, Nov 03, 2009 at 02:23:28PM -0500, Akhil Jaggarwal wrote:

> Any tips or hints on a query which removes all the inner holes from a
> polygon and returns and keeps the geometry of the largest one intact?

SELECT ST_ExteriorRing(geometry)  ...

--strk;

 Free GIS & Flash consultant/developer      ()  ASCII Ribbon Campaign
 http://foo.keybit.net/~strk/services.html  /\  Keep it simple!
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users

Re: Removing holes from polygons

by Paragon Corporation-2 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

You probably want to do a ST_Dump as well if you are talking about
Multipolygons and also exterior ring returns the linestring -- need to use
ST_MakePolygon to turn it back into a polygon

SELECT s.gid, ST_Collect(ST_MakePolygon(s.the_geom)) As the_geom
FROM (SELECT gid, ST_ExteriorRing((ST_Dump(the_geom)).geom) As the_geom
 FROM sometable )  As s
 GROUP BY gid;

Leo

-----Original Message-----
From: postgis-users-bounces@...
[mailto:postgis-users-bounces@...] On Behalf Of strk
Sent: Tuesday, November 03, 2009 3:15 PM
To: PostGIS Users Discussion
Subject: Re: [postgis-users] Removing holes from polygons

On Tue, Nov 03, 2009 at 02:23:28PM -0500, Akhil Jaggarwal wrote:

> Any tips or hints on a query which removes all the inner holes from a
> polygon and returns and keeps the geometry of the largest one intact?

SELECT ST_ExteriorRing(geometry)  ...

--strk;

 Free GIS & Flash consultant/developer      ()  ASCII Ribbon Campaign
 http://foo.keybit.net/~strk/services.html  /\  Keep it simple!
_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users



_______________________________________________
postgis-users mailing list
postgis-users@...
http://postgis.refractions.net/mailman/listinfo/postgis-users