I a hunch that this is the crux of your problem: Since p1 -- as a "bowtie" -- is non-simple, part of it is "inside out" (with respect to the conventional winding rules). The buffer() operation is -- perhaps by design -- not returning the buffered version of the "inside out" portion.
This seems to work (and seems to corroborate the above hunch): p1r = Polygon(list(reversed(p1.exterior.coords)) p2r = p1r.buffer(0) Since p1r is "inside out" in the "other sense", the buffer() operation seems to return the "other part" of the bowtie. Thus the union of p2 and p2r seem to be what you are looking for. If that doesn't work for you and your complex polygon, I can think of a way that is more general, but probably at the expense of using more computations. Here is an outline: * Split up the complex/non-simple polygon in to its constituent LinearRings or LineStrings or line segments. * Use "cascaded_union" to node all the lines (where they intersect) * Use "polygonize" to stitch back together constituent polygons That works for me, too, but the code snippet is a bit long; let me know if you'd like me to post it, and/or send it to you directly. Cheers, Dan Harasty -----Original Message----- From: community-boun...@lists.gispython.org [mailto:community-boun...@lists.gispython.org] On Behalf Of Robert Sanson Sent: Monday, April 28, 2014 9:57 PM To: gispython.org community projects Subject: [Community] bowtie problem Hi All I am trying to use shapely to fix an invalid polygon with a massive bowtie: import shapely from shapely.wkt import loads p1 = loads('POLYGON((0 0, 2 2, 2 0, 0 2 ,0 0))') p2 = p1.buffer(0) p2.wkt returns 'POLYGON ((1 1, 2 2, 2 0, 1 1))' I am losing half the original polygon. How can I get a full valid polygon back? Many thanks, Robert Sanson This email and any attachments are confidential and intended solely for the addressee(s). If you are not the intended recipient, please notify us immediately and then delete this email from your system. This message has been scanned for Malware and Viruses by Websense Hosted Security. www.websense.com<http://www.websense.com> _______________________________________________ Community mailing list Community@lists.gispython.org<mailto:Community@lists.gispython.org> http://lists.gispython.org/mailman/listinfo/community
_______________________________________________ Community mailing list Community@lists.gispython.org http://lists.gispython.org/mailman/listinfo/community