On Tue, Nov 9, 2010 at 4:35 PM, D. A. Follensbee <[email protected]>wrote:
> Hello, > > I'm a relative newbie to Shapely, and I noticed in the documentation that > buffering a polygon to 0 -- ie: pPoly.buffer(0) -- can clean a polygon that > self intersects. I use the is_valid boolean to see if the polygon self > intersects and run the .buffer(0) when it does self intersect. I'm using > Shapely 1.2.5 and Python 2.5.4 on Windows 7. > > Passed a distance of 0, > buffer()<http://gispython.org/shapely/docs/1.2/manual.html#object.buffer>can > be used to “clean” self-touching or self-crossing polygons such as the > classic “bowtie”. > > Buffering to 0 works very well 90% of the time, returning the polygons that > form the self intersecting polygon, ie bowtie. I've found that if one of the > resulting polygons is small - not sure what tolerance this is - it will not > be returned by the buffer. In many cases, I want this to occur. For example, > if polygon self touches and creates a line in the result, I'm okay with that > vanishing. The problem is when I expect to receive polygons, sometimes a > resulting small polygon will vanish. Right now, my polygon coordinates are > rounded to 5 digits of precision. > > In the two WKT polygons below, the first polygon is the original polygon > and the second is the zero buffer version. Part of the resulting polygon is > dropped - on the southern edge of the feature. I've performed this same > operation with FME's self intersect transformer, and it preserves the sliver > portion of the polygon. In many situations, I'd like to keep and analyze > these slivers and make a decision based on it. I do not necessarily want to > remove it. I have attempted to adjust the resolution to many different > numbers and receive no change in the output. > > Is this the expected behavior, and if so, is there a size tolerance to the > features returned? > > Any help is appreciated! > > > POLYGON ((-75.5979600000000005 38.4566900000000018, -75.5979899999999958 > 38.4569699999999983, -75.5980899999999991 38.4571499999999986, > -75.5981400000000008 38.4572100000000034, -75.5983499999999964 > 38.4573699999999974, -75.5983700000000027 38.4574199999999990, > -75.5983999999999980 38.4574799999999968, -75.5984100000000012 > 38.4575400000000016, -75.5983999999999980 38.4575999999999993, > -75.5983599999999996 38.4576599999999971, -75.5983099999999979 > 38.4577099999999987, -75.5982099999999946 38.4577699999999965, > -75.5979099999999988 38.4579000000000022, -75.5974899999999934 > 38.4580300000000008, -75.5973999999999933 38.4580899999999986, > -75.5973500000000058 38.4581500000000034, -75.5972900000000010 > 38.4582800000000020, -75.5972699999999946 38.4584899999999976, > -75.5973599999999948 38.4588499999999982, -75.5973699999999980 > 38.4589500000000015, -75.5973599999999948 38.4591800000000035, > -75.5973800000000011 38.4592400000000012, -75.5974700000000013 > 38.4592799999999997, -75.5976200000000063 38.4593399999999974, > -75.5977100000000064 38.4593899999999991, -75.5978000000000065 > 38.4594900000000024, -75.5978499999999940 38.4596200000000010, > -75.5978999999999957 38.4597800000000021, -75.5979099999999988 > 38.4599499999999992, -75.5979099999999988 38.4599699999999984, > -75.5970700000000022 38.4624099999999984, -75.5967799999999954 > 38.4636700000000005, -75.5962099999999992 38.4633600000000015, > -75.5944899999999933 38.4624299999999977, -75.5939199999999971 > 38.4621199999999988, -75.5928499999999985 38.4615599999999986, > -75.5918599999999969 38.4610300000000009, -75.5896699999999981 > 38.4598399999999998, -75.5885999999999996 38.4592699999999965, > -75.5880099999999970 38.4589500000000015, -75.5870800000000003 > 38.4584499999999991, -75.5865600000000057 38.4581700000000026, > -75.5862300000000005 38.4579900000000023, -75.5856399999999979 > 38.4576700000000002, -75.5854099999999960 38.4575499999999977, > -75.5850099999999969 38.4573400000000021, -75.5847200000000043 > 38.4571800000000010, -75.5845000000000056 38.4570599999999985, > -75.5841400000000050 38.4568700000000021, -75.5838899999999967 > 38.4567300000000003, -75.5835699999999946 38.4565500000000000, > -75.5832699999999988 38.4564700000000030, -75.5830500000000001 > 38.4564000000000021, -75.5826699999999931 38.4562799999999996, > -75.5829599999999999 38.4561700000000002, -75.5835699999999946 > 38.4561899999999994, -75.5839500000000015 38.4562000000000026, > -75.5843700000000069 38.4562099999999987, -75.5863200000000006 > 38.4562700000000035, -75.5863400000000070 38.4562700000000035, > -75.5872600000000006 38.4562999999999988, -75.5872800000000069 > 38.4562999999999988, -75.5875300000000010 38.4563100000000020, > -75.5875300000000010 38.4563100000000020, -75.5884099999999961 > 38.4563300000000012, -75.5884099999999961 38.4563300000000012, > -75.5887500000000045 38.4563399999999973, -75.5889200000000017 > 38.4563399999999973, -75.5890200000000050 38.4563199999999981, > -75.5892000000000053 38.4563699999999997, -75.5893499999999960 > 38.4564000000000021, -75.5896500000000060 38.4564299999999974, > -75.5897400000000061 38.4564400000000006, -75.5904500000000041 > 38.4564799999999991, -75.5915700000000044 38.4565199999999976, > -75.5918499999999938 38.4565300000000008, -75.5923999999999978 > 38.4565399999999968, -75.5930900000000037 38.4565600000000032, > -75.5936700000000030 38.4565699999999993, -75.5945300000000060 > 38.4565899999999985, -75.5945899999999966 38.4565899999999985, > -75.5945999999999998 38.4566099999999977, -75.5973199999999963 > 38.4566700000000026, -75.5949200000000019 38.4566000000000017, > -75.5974400000000060 38.4566799999999986, -75.5975600000000014 > 38.4566799999999986, -75.5976900000000001 38.4566900000000018, > -75.5977400000000017 38.4566900000000018, -75.5978999999999957 > 38.4566900000000018, -75.5979600000000005 38.4566900000000018)) > > > POLYGON ((-75.5979600000000005 38.4566900000000018, -75.5979899999999958 > 38.4569699999999983, -75.5980899999999991 38.4571499999999986, > -75.5981400000000008 38.4572100000000034, -75.5983499999999964 > 38.4573699999999974, -75.5983700000000027 38.4574199999999990, > -75.5983999999999980 38.4574799999999968, -75.5984100000000012 > 38.4575400000000016, -75.5983999999999980 38.4575999999999993, > -75.5983599999999996 38.4576599999999971, -75.5983099999999979 > 38.4577099999999987, -75.5982099999999946 38.4577699999999965, > -75.5979099999999988 38.4579000000000022, -75.5974899999999934 > 38.4580300000000008, -75.5973999999999933 38.4580899999999986, > -75.5973500000000058 38.4581500000000034, -75.5972900000000010 > 38.4582800000000020, -75.5972699999999946 38.4584899999999976, > -75.5973599999999948 38.4588499999999982, -75.5973699999999980 > 38.4589500000000015, -75.5973599999999948 38.4591800000000035, > -75.5973800000000011 38.4592400000000012, -75.5974700000000013 > 38.4592799999999997, -75.5976200000000063 38.4593399999999974, > -75.5977100000000064 38.4593899999999991, -75.5978000000000065 > 38.4594900000000024, -75.5978499999999940 38.4596200000000010, > -75.5978999999999957 38.4597800000000021, -75.5979099999999988 > 38.4599499999999992, -75.5979099999999988 38.4599699999999984, > -75.5970700000000022 38.4624099999999984, -75.5967799999999954 > 38.4636700000000005, -75.5962099999999992 38.4633600000000015, > -75.5944899999999933 38.4624299999999977, -75.5939199999999971 > 38.4621199999999988, -75.5928499999999985 38.4615599999999986, > -75.5918599999999969 38.4610300000000009, -75.5896699999999981 > 38.4598399999999998, -75.5885999999999996 38.4592699999999965, > -75.5880099999999970 38.4589500000000015, -75.5870800000000003 > 38.4584499999999991, -75.5865600000000057 38.4581700000000026, > -75.5862300000000005 38.4579900000000023, -75.5856399999999979 > 38.4576700000000002, -75.5854099999999960 38.4575499999999977, > -75.5850099999999969 38.4573400000000021, -75.5847200000000043 > 38.4571800000000010, -75.5845000000000056 38.4570599999999985, > -75.5841400000000050 38.4568700000000021, -75.5838899999999967 > 38.4567300000000003, -75.5835699999999946 38.4565500000000000, > -75.5832699999999988 38.4564700000000030, -75.5830500000000001 > 38.4564000000000021, -75.5826699999999931 38.4562799999999996, > -75.5829599999999999 38.4561700000000002, -75.5835699999999946 > 38.4561899999999994, -75.5839500000000015 38.4562000000000026, > -75.5843700000000069 38.4562099999999987, -75.5863200000000006 > 38.4562700000000035, -75.5863400000000070 38.4562700000000035, > -75.5872600000000006 38.4562999999999988, -75.5872800000000069 > 38.4562999999999988, -75.5875300000000010 38.4563100000000020, > -75.5884099999999961 38.4563300000000012, -75.5887500000000045 > 38.4563399999999973, -75.5889200000000017 38.4563399999999973, > -75.5890200000000050 38.4563199999999981, -75.5892000000000053 > 38.4563699999999997, -75.5893499999999960 38.4564000000000021, > -75.5896500000000060 38.4564299999999974, -75.5897400000000061 > 38.4564400000000006, -75.5904500000000041 38.4564799999999991, > -75.5915700000000044 38.4565199999999976, -75.5918499999999938 > 38.4565300000000008, -75.5923999999999978 38.4565399999999968, > -75.5930900000000037 38.4565600000000032, -75.5936700000000030 > 38.4565699999999993, -75.5945300000000060 38.4565899999999985, > -75.5945899999999966 38.4565899999999985, -75.5945999999999998 > 38.4566099999999977, -75.5966809638556327 38.4566559036144611, > -75.5974400000000060 38.4566799999999986, -75.5975600000000014 > 38.4566799999999986, -75.5976900000000001 38.4566900000000018, > -75.5977400000000017 38.4566900000000018, -75.5978999999999957 > 38.4566900000000018, -75.5979600000000005 38.4566900000000018)) > This is likely a robustness issue of GEOS/JTS, and not really a Shapely question (and the Shapely list doesn't have the experts to answer it either). You will have more interested in your well posed question on the geos-devel list. Because it comes with good examples of how to demonstrate the problem, it has a great chance at interesting some of those experts as well. Thanks, Howard
_______________________________________________ Community mailing list [email protected] http://lists.gispython.org/mailman/listinfo/community
