I have a list of Shapely polygons in Python. To find out which touch of the polygon is easy, use the method .touches(). However, I need something that returns Trueonly when polygons share more than one point (in other words, share a border). Let me illustrate:
In [1]: from shapely.geometry import Polygon
In [2]: polygons = [Polygon([(0,0),(0,1),(1,1),(1,0)]), Polygon([(1,0),(1,1),(2,1),(2,0)]), Polygon([(2,1),(2,2),(3,2),(3,1)])]
In [3]: polygons[0].touches(polygons[1])
Out[3]: True
In [4]: polygons[0].touches(polygons[2])
Out[4]: False
In [5]: polygons[1].touches(polygons[2])
Out[5]: True
In this case, the polygon 0 and 1 separates the two points (the whole border). Polygon 1 and 2 share only one point. What I am looking for a function that will give me True, False, Falsein the example above, or just something that returns the number of points of contact, then I can perform the rest of the logic of its own.
And, of course, any solution that does not involve manual iteration over all points is optimal - if I need to do this, it does not seem to match the purpose of using Shapely :-)