[postgis-users] Combining squares

Brian Peschel brianp at occinc.com
Tue Dec 22 13:02:11 PST 2009


Hi Brian,
>    
>> I have squares.  A lot of squares.  Thousands of squares.  I would
>> love
>> to combine them into one or more larger polygons.  But, they must
>> valid
>> polygons, non-reentrant.  For example. if you have a 3x3 grid of
>> squares,
>> ABC
>> RST
>> XYZ
>> and I want to combine all but the center, I would need either 2
>> polygons
>> (something like ABC and RXYZT), or one polygon with an inner ring.
>>      
> Assuming there is a table 'squares' containing a geometry type 'the_geom', this one produces a polygon having an inner ring:
>
> SELECT
> ST_Difference(ST_Union(the_geom), (SELECT the_geom FROM squares WHERE id='S'))
> FROM squares
>
> Best Regards,
> Andreas
>    

Does this return a multipolyon or a single polygon?  I didn't state this 
originally, but I have disjointed squares.  So if you look at a grid:
ABCDEF
OPQRST
UVWXYZ
I might have ABCEFOQUVW
ABC EF
O Q
UVW
So I would want one polygon with ABCQWVU and one with EF

- Brian
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20091222/a754ea21/attachment.html>


More information about the postgis-users mailing list