[postgis-users] Buffer() creates invalid polygons??

Mark Fenbers Mark.Fenbers at noaa.gov
Tue May 24 04:52:40 PDT 2005


I use the Buffer() function on a point to get a circular polygon 
(hereafter just called "circle").  I then later subtract away a 
rectangle (which partially overlaps the circle) using the Difference() 
function.  This fails for about 20% (4 of 20) of the circles I compute.  
The error I get is:

NOTICE:  TopologyException: no outgoing dirEdge found 
(-103879.654,348793.58)
ERROR:  GEOS difference() threw an error

I have found by accident that if I adjust the third argument to the 
Buffer() function, the error goes away for some circles, yet appears for 
others.  For the 80% (16 of 20) of successes with the Difference() 
function, I used circles computed from "Buffer(the_geom, 231500.0, 
90)".  If I use 91 instead of 90, then I can get 2 or 3 (of the four 
that failed) to work without failing in the Difference() function, but 
then 2 or three others fail that had worked when the third Buffer() arg 
was set to 90.

Eventually, I got all 20 of the circles to work using the Difference() 
function, but I had to run the query one circle at a time, and play with 
the value of Buffer()'s third arg until I found a value that worked for 
that particular circle.  I shouldn't have to do this and suspect the 
problem is a bug.  If needed, I can produce the SQL and the table 
containing the points.

I am positive the problem is with the circles, and not the rectangles 
I'm subtracting from them, because when the Difference() function fails 
for a particular circle, it fails no matter what rectangle I use, and 
when I "fix" the circle by adjusting Buffer()'s third arg, it works for 
any rectangle I throw at it...

Oh, I almost forgot to mention what the subject line refers to... Even 
when the Difference() function fails (and other functions like 
Intersection, GeomUnion, and SymDifference() fail also), the IsValid() 
function reports that the polygon *IS* a valid geometry.  I've made sure 
that both the circle and the rectangle pass the IsValid() test before 
feeding them to the Difference() function, but for some circles, 
Difference() still fails.  I don't mean to pick on the Difference() 
function as I think the problem exists in the Buffer() function 
instead.  But I'll leave this for experts to determine...

Mark
-------------- next part --------------
A non-text attachment was scrubbed...
Name: Mark.Fenbers.vcf
Type: text/x-vcard
Size: 283 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/postgis-users/attachments/20050524/1c2956c6/attachment.vcf>


More information about the postgis-users mailing list