[postgis-users] Boundary() without the internal holes?

John Carnes john at maptools.com
Thu Mar 1 09:25:11 PST 2007


Thanks Brad,

ExteriorRing() did the job.

For the benefit of list searchers in the future...

The problem at hand was to create a boundary around a bunch of land  
parcels that make up a neighborhood.
The space taken up by the streets is "empty" in that there is no  
polygon to represent it.

Step 1 was to add a neighborhood attribute and get it set to the  
correct value.

Step 2 was to add some small polygons to block off the street  
openings at the boundaries of the neighborhood. I gave them all a  
special tag that makes it easy to remove them when I'm finished.

Step 3 was to create the boundary using the ExteriorRing() function.

The query for an individual neighborhood looks like this:

INSERT INTO n_bounds (neighborhood,the_geom) SELECT  
p.neighborhood,MakePolygon(ExteriorRing(geometryN(geomunion 
(p.the_geom),1)))
FROM parcels AS p WHERE p.neighborhood=6;

Form a computational standpoint, I suspect this query is a disaster,  
but this is a one time shape generation, so waiting a bit longer for  
the result makes no difference.

John Carnes
MapTools

On Feb 28, 2007, at 3:57 PM, Brad Ediger wrote:

> Sounds like you're looking for ExteriorRing(polygon). A polygon has  
> one exterior ring and zero or more interior rings. ExteriorRing is  
> a lot cheaper (computationally) than calculating a convex hull or  
> boundary.
>
> Documentation here -> http://postgis.refractions.net/docs/ch06.html
>
> Brad
>
> On Feb 28, 2007, at 5:30 PM, John Carnes wrote:
>
>> I am trying to figure out how to get a polygon that is the  
>> boundary of a geounion of polygons without getting polygons for  
>> the internal holes.
>>
>> The boundary() function is close, but includes the internal holes.
>>
>>     SELECT boundary(geomunion(p.the_geom)) FROM parcels AS p WHERE  
>> p.neighborhood=5;
>>
>> A convex hull, leaves out the internal holes, but the resulting  
>> polygon doesn't touch the actual boundary anywhere that it is  
>> concave.
>>
>> Thanks in advance for your ideas on how to do this.
>> I'd really like to avoid having to delete the internal hole  
>> polygons by hand, which is my current solution.
>>
>> John Carnes
>> MapTools




More information about the postgis-users mailing list