[postgis-users] unioning a buffer - bug?

L Bogert-OBrien dlawbob at ncf.ca
Tue Sep 14 09:47:34 PDT 2010


You know this is a similar problem to what I was experiencing when I
asked what was the difference between ST_Union and ST_Collect.  When I
got the topological errors thrown from the ST_Union, there was a NULL
result in the geometry field for each area that had an error.  See
http://postgis.refractions.net/pipermail/postgis-users/2010-September/027653.html
 and yes indeed I made a typo when asking the question.  I replaced
ST_UNION with ST_COLLECT and not ST_DUMP with ST_COLLECT and got a
result with no error, however, I do not think it is the result I want,
since as Nicklas pointed out ST_Collect just blindly adds all the
polygons into a multipolygon, whereas ST_Union tries to dissolve them. 
Why does ST_Union have trouble dissolving polygons that overlap in
certain ways that result in the errors thrown? (TopologyException: found
non-noded intersection between... or
TopologyException: Directed Edge visited twice during ring-building...)  

I see how these TopologyExceptions would happen when you buffer with a
small number or when like me you eliminate certain small parts of the
multipolygons.

Regards,

Loretta
-------------- next part --------------
How are you determining you have no results?

Try:
CREATE TABLE results AS
SELECT st_union(st_buffer(the_geom,0.1)) as the_geom
FROM base.current_assessment_parcel;

SELECT count(*) FROM results;
SELECT ST_Summary(the_geom) FROM results;

Unioning a buffer shouldn't be problematic:

SELECT ST_AsText(
   ST_Union(
     ST_Buffer(column1, 0.1)
   )
)
FROM (VALUES
   ('POLYGON((1 1, 1 2, 2 2, 1 1))'::geometry),
   ('POLYGON((1 1, 2 2, 2 1, 1 1))'::geometry)
) as v;

POLYGON ((
         1 0.9,
         0.980490967798387 0.901921471959677,
         0.961731656763491 0.907612046748871,
         0.96173165676349 0.907612046748872,
         0.954928240996994 0.911248548238567,
         0.94444297669804 0.916853038769746,
         0.929289321881345 0.929289321881345,
         0.929289321881345 0.929289321881346,
         0.916853038769745 0.94444297669804,
         0.90817310697871 0.960681986902375,
         0.907612046748871 0.961731656763491,
         0.901921471959677 0.980490967798388,
         0.900377969797711 0.996162408242473,
         0.9 1,
         0.9 2,
         0.901921471959677 2.01950903220161,
         0.907612046748871 2.03826834323651,
         0.916853038769745 2.05555702330196,
         0.929289321881345 2.07071067811865,
         0.94444297669804 2.08314696123025,
         0.961731656763491 2.09238795325113,
         0.980490967798387 2.09807852804032,
         1 2.1,
         2 2.1,
         2.01950903220161 2.09807852804032,
         2.03826834323651 2.09238795325113,
         2.05555702330196 2.08314696123025,
         2.07071067811865 2.07071067811865,
         2.08314696123025 2.05555702330196,
         2.09238795325113 2.03826834323651,
         2.09807852804032 2.01950903220161,
         2.1 2,
         2.1 1,
         2.09807852804032 0.980490967798387,
         2.09238795325113 0.961731656763491,
         2.08314696123025 0.94444297669804,
         2.07071067811865 0.929289321881345,
         2.05555702330196 0.916853038769745,
         2.03826834323651 0.907612046748871,
         2.01950903220161 0.901921471959677,
         2 0.9,
         1 0.9
     ))

-- Kevin

On 9/13/2010 7:07 AM, Lee wrote:
> So after some googling I see similar problems, but no solutions posted.
>
> I am trying to union a buffer, but the query is returning no results.  
> Here is ultimately what I would like to achieve:
>
> select st_union(st_buffer(the_geom,0.1)) as the_geom from 
> base.current_assessment_parcel
>
> Here are some troubleshooting steps I have taken to try narrow it down:
>
> select st_isvalid(the_geom) a from base.current_assessment_parcel 
> group by a
> TRUE
>
> select st_isvalid(st_buffer(the_geom,0.1)) a from 
> base.current_assessment_parcel group by a
> TRUE
>
> select st_isvalid(st_union(the_geom)) from base.current_assessment_parcel
> TRUE
>
> select st_isvalid(st_union(st_buffer(the_geom,0.1))) from 
> base.current_assessment_parcel
> NOTICE:  TopologyException: found non-noded intersection between 
> 586714 4.95189e+006, 586714 4.95189e+006 and 586714 4.95189e+006, 
> 586739 4.9519e+006 586714 4.95189e+006
> Total query runtime: 859 ms.
> 1 row retrieved.
> (returns blank record)
>
>  And just for fun
> select st_isvalid(st_buffer(st_union(the_geom),0.1)) a from 
> base.current_assessment_parcel
> TRUE
>
> I guess my next step would be to try the snap to grid functions, but 
> the first query above should work, shouldn't it?
>
> Any help appreciated. Thanks.
> Lee
>
>
> _______________________________________________
> postgis-users mailing list
> postgis-users at postgis.refractions.net
> http://postgis.refractions.net/mailman/listinfo/postgis-users
>    
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20100914/8c0374c3/attachment.html>
-------------- next part --------------
_______________________________________________
postgis-users mailing list
postgis-users at postgis.refractions.net
http://postgis.refractions.net/mailman/listinfo/postgis-users


More information about the postgis-users mailing list