[postgis-users] Combining squares
Andreas
ml at 3.141592654.de
Mon Dec 21 13:50:01 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
More information about the postgis-users
mailing list