-
Notifications
You must be signed in to change notification settings - Fork 608
Open
Labels
Description
Expected behavior and actual behavior.
I have two polygons which are extremely similar to each other and I intersect them both with a third polygon. I expect the intersection to be a large polygon, but in one case I end up with a point.
Steps to reproduce the problem.
from shapely import wkt
from shapely.ops import orient
zone = wkt.loads('POLYGON ((79.57006468414316 227.16715306136757, 43.44048377114246 -7.28462320799008, 127.74283932445364 -13.587090929970145, 154.99848808655608 219.60419326741248, 79.57006468414316 227.16715306136757))')
geom_0 = wkt.loads('POLYGON ((127.74283932445364 -13.587090929970145, 43.44048377114247 -7.28462320799008, 54.329847263553376 63.37854389007508, 54.61818554266568 63.33040101339976, 135.62637080265046 53.862076963892896, 127.74283932445364 -13.587090929970145))')
geom_0.intersection(zone).wkt # outputs 'POINT (127.74283932445364 -13.587090929970145)'
# yet orienting geom_0 first, gives a polygon
orient(geom_0).intersection(zone).wkt # 'POLYGON ((127.74283932445364 -13.587090929970145, 43.44048377114247 -7.28462320799008, 54.329847263553376 63.37854389007508, 54.61818554266568 63.33040101339976, 135.62637080265046 53.862076963892896, 127.74283932445364 -13.587090929970145))'
# this geometry is almost exactly the same as geom_0
geom_1 = wkt.loads('POLYGON ((127.74283932445363 -13.587091019377114, 43.44048377114246 -7.284623297862709, 54.32984726350768 63.37854379976558, 54.61818554261504 63.33040092309082, 135.62637080259915 53.862076873508386, 127.74283932445363 -13.587091019377114))')
geom_1.intersection(zone).wkt # outputs 'POLYGON ((54.32984726350768 63.37854379976558, 54.61818554261504 63.33040092309082, 135.6263707922279 53.862076874720586, 127.74283932445364 -13.587090929970145, 43.440483784834306 -7.284623209013686, 54.32984726350768 63.37854379976558))'
# another observation
geom_0.intersection(zone) # is a point
zone.intersection(geom_0) # is a point
# but
zone.buffer(0).intersection(geom_0) # is a polygon
geom_0.buffer(0).intersection(zone) # is a pointOperating system
Debian 5.19.11
Shapely version and provenance
Shapely 1.8.2 installed with pip