contains() fails on intersection between to polygons
See original GitHub issueExpected behavior and actual behavior.
p1
and p2
are Polygon instances.
intr
is the intersection between them.
p1.contains(intr)
should return True
but it doesn’t. Same for p2
It seems like the method contains()
fails, as the intersection seems to be done properly (visually)
Might be some numeric issue but not sure if or how to overcome it.
Steps to reproduce the problem.
p1_coords = \
[[748.8025582487921, 692.7905130423437],
[758.386063090365, 677.1925344087617],
[782.1652203101282, 676.7231091250326],
[788.8580742086473, 683.1149159561049],
[868.0049913065219, 683.6289962743791],
[926.8683108501167, 689.7558195905867],
[945.7907193468513, 708.439577587113],
[1039.6537221843691, 703.381222940517],
[1066.324798875523, 680.7152398075801],
[1133.224871450568, 689.92869220046],
[1222.5475564764015, 692.7897316662702],
[1277.5144968118584, 684.5672802321901],
[1328.0021558805488, 676.1621265825976],
[1326.815087867148, 619.5785512771574],
[1299.7103682278287, 615.8195025680548],
[1295.2342048657717, 591.626525113616],
[1274.7539157178887, 590.5506388538025],
[1202.0978166597627, 592.7976585977345],
[1136.907474756592, 593.9744014790401],
[1084.7358589468115, 591.2979988449307],
[1054.321591743031, 608.3179374482914],
[1047.6196314231581, 601.1199745285347],
[1034.804148286642, 594.4689776634423],
[949.9981449369338, 593.7064099888793],
[940.4460280909863, 595.3257907811172],
[924.4796508201753, 595.2980651204466],
[871.9387738363519, 595.6476008591529],
[810.8642644301572, 596.052802923398],
[769.0652199778682, 597.2038897158519],
[720.046350378694, 600.7688245694075],
[648.8434044602943, 601.2850228232351],
[642.9491158104589, 607.2758337282743],
[641.7129825986358, 620.3276349838853],
[614.2839898484269, 619.8007952616304],
[616.6784871475897, 693.9077179629917],
[641.3952794887201, 696.957078173488],
[647.9645013441202, 706.4594586892523],
[735.7974745282122, 701.1862915610103]]
p2_coords = \
[[738.4203560383309, 691.7622240616488],
[748.5093491295943, 676.1691997515779],
[772.3499404302023, 675.7342536373502],
[778.8724641068089, 682.1307596677275],
[852.6315789473684, 654.9473684210527],
[912.4510044327204, 688.7034730557052],
[931.9894048538762, 706.3806230658993],
[1026.4831479732457, 705.8026066911324],
[1055.555109984319, 680.1104614031487],
[1121.8072774161926, 689.3606976743876],
[1211.815557636787, 694.8791651191065],
[1265.070256365337, 687.6893857680409],
[1318.132168061228, 672.6966585838568],
[1319.2148971104832, 619.4745622702778],
[1297.4406122647656, 616.6996353170073],
[1281.7452211311079, 589.8756230593528],
[1261.3858732724157, 591.5322213239801],
[1190.7847207965747, 592.641429891231],
[1127.2910885285871, 592.8204989948874],
[1074.6293839169564, 591.7285619427223],
[1047.5117346247594, 607.3954488302268],
[1037.8991398844898, 601.2910510553994],
[1025.3179858858186, 594.7076173369253],
[941.4380178004869, 593.7196866948717],
[931.9447451893386, 595.2893266248864],
[916.1180159026535, 595.2176239325067],
[863.9671006403921, 595.4164703212768],
[803.2269595172519, 595.6469749150042],
[761.5573616087426, 596.6691028549511],
[712.5359251472214, 600.0629088525174],
[641.316892849315, 600.381622070341],
[635.1911323054353, 606.30835831528],
[632.654875020185, 617.7509840311711],
[606.7908837439835, 619.6833511954851],
[607.9800327681767, 691.4782235311482],
[633.8669700854907, 695.7953585646385],
[636.1433061564386, 705.3368220396302],
[725.0971110529704, 700.1624087171722]]
p1 = Polygon(p1_coords)
p2 = Polygon(p2_coords)
intr = p1.intersection(p2)
print(p1.contains(intr)) # should return True but doesn't
print(p2.contains(intr)) # should return True but doesn't
Operating system
Ubuntu 16.04
Shapely version and provenance
1.6.2.post1 installed from PyPI using pip
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (2 by maintainers)
Top Results From Across the Web
contains() fails on intersection between to polygons · Issue #562
Same for p2 It seems like the method contains() fails, as the intersectio... ... contains() fails on intersection between to polygons #562.
Read more >Error calculating intersection between Polygon and Multipolygon
I found st_intersection() worked when I replaced poly1 , the Multipolygon, with poly1[[2]] . It returned the output as a Polygon and a ......
Read more >Non-noded intersection issues from overlapping buffer objects
I am working with valid lat/lon point data, creating buffers, and trying to calculate overlapping areas from buffers and running into the not-so ......
Read more >Intersect between multiple points and polygons / g...
Hi Irrespective of what I try I cannot do an intersect between multiple points and multiple polygons and neither can I save the...
Read more >How Pairwise Intersect works—ArcGIS Pro | Documentation
The Pairwise Intersect tool calculates the intersection between the features in two feature layers or feature classes using a pairwise comparison technique.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Oh, now i get it. Yes, of course. Thanks
On Feb 2, 2018 3:24 PM, “Sean Gillies” notifications@github.com wrote:
@yoelk https://github.com/yoelk sorry, i’m not going to accept the patch because contains works fine, it’s the intersection method that is in error here.
— You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub https://github.com/Toblerity/Shapely/issues/562#issuecomment-362597290, or mute the thread https://github.com/notifications/unsubscribe-auth/AGTaG4qKNORl6BDnRCJET406o9tAdOlRks5tQxg3gaJpZM4RyNaB .
@yoelk sorry, i’m not going to accept the patch because
contains
works fine, it’s theintersection
method that is in error here.