polygon - Shapely intersection function not giving desired result - Stack Overflow

admin2025-04-18  2

I am using python to work on polygons. I want to find intersection of two polygons and then find the intersection of the intersected polygon with two lines.the intersection of a polygon with a line should ideally give a shapely line or point element if intersection is not empty.

In this image (Polygons to intersect), i am finding the intersection of two yellow polygons using

polygon1.intersection(polygon2)

The base of these two yellow polygons are the two red lines to the left and to the right.

Intersection of these two polygons looks like: intersected polygon

Now from geometry, the intersection of this intersected polygon with the left and right red lines should also give a shapely line element. I do the intersection as:

intersected_polygon.intersection(left_line)
intersected_polygon.intersection(right line_line)

Intersection with the left line returns a shapely line element however intersection with the right line gives a shapely point element.

I am not able to understand why is shapely returning a Point when it should clearly return a line as the polygon's base is on this line.

Is there something about how shapely works that I am missing?

Any help in this matter would be appreciated.

Thanks.

转载请注明原文地址:http://anycun.com/QandA/1744958608a90037.html