[postgis-users] union operation

Kevin Neufeld kneufeld at refractions.net
Fri Aug 7 08:39:22 PDT 2009


lighthousej at gmail.com wrote:
> The geometries themselves look okay, they specify polygons that have 
> some area.

Unfortunately, computing area is not indicative of valid geometries.  For example, consider this polygon that has a hole 
that extends outside of the polygon, but still returns an area ... whatever that might mean.

SELECT ST_IsValid(geom), ST_Area(geom)
FROM (
   SELECT '
     POLYGON(
       (1 1, 1 4, 4 4, 4 1, 1 1),
       (2 2, 5 6, 6 6, 6 5, 2 2)
     )'::geometry AS geom
) AS foo;
NOTICE:  Self-intersection at or near point 4 3.5
  st_isvalid | st_area
------------+---------
  f          |       5
(1 row)



> Any more things to look at would be much appreciated.

As Regina eluded to, if you've ruled out geometry validity as the problem, it may be st_union is running into precision 
issues.  Try putting your geometries through ST_SnapToGrid()

Cheers,
-- Kevin




More information about the postgis-users mailing list