Shapely Intersections Vs Shapely Relationships - Inexact?
I wonder if I am thinking the wrong way or if this is a bug: I have a linestring and a polygon, I create the intersection points of the line and the polygon's boundary These inter
Solution 1:
It's not a bug, but this is a frequent question.
Without a precision model, all floating point calculations are limited by the machine epsilon. The intersected points are interpolated from each geometry, and are seldom exact (unless you have right angles). All of the DE-9IM predicates like 'touches' currently require exact noding (unless we have a precision model, which might happen one day UPDATE: testing with JTS Topology Suite, the DE-9IM predicates don't use the precision model, therefore it is unlikely that the GEOS clone will work any different).
A more robust strategy is to test the distance between the two, which should be less than the machine epsilon if they intersect. E.g.:
EPS = 1e-15
for i in ips:
print(i.distance(poly) < EPS)
Post a Comment for "Shapely Intersections Vs Shapely Relationships - Inexact?"