Hi Sean,
> > 1) How can I manipulate the two polygons so that I can run the
> > difference operation ?
>
> This I do not know. I do believe that this issue should be reported in
> the GEOS tracker.
Meanwhile I have implemented a workaround whcih I believe could be a
valuable addition to shapely. If the difference operation fails on a
TopologicalError, I try the following alternative :
try:
diff_p = p2.difference(p1)
except TopologicalError, err:
if isinstance(p1, MultiPolygon):
diffs = []
for p1pol in p1.geoms:
d = p2.difference(p1pol)
diffs.append(d)
diff_p = diffs[0]
for d in diffs[1:]:
diff_p = diff_p.intersection(d)
elif isinstance(p2, MultiPolygon):
diffs = []
for p2pol in p2.geoms:
d = p2pol.difference(p1)
diffs.append(d)
diff_p = MultiPolygon(diffs)
else:
raise err
This workaround does not cover all cases, but it is able to give a
correct solution in some cases that would otherwise fail.
wbr
Emmanuel
_______________________________________________
Community mailing list
[email protected]
http://lists.gispython.org/mailman/listinfo/community