Я попробовал упростить, а затем посчитать, если количество координат равно 5...
Код: Выделить всё
>>> from shapely.geometry import Polygon
>>> from shapely.ops import split
>>>
>>> poly1 = Polygon([(0, 0), (0, 1), (0, 3), (2, 3), (2, 2), (2, 0), (0, 0)])
>>>
>>> poly_check=poly1.simplify(0)
>>> if len(poly_check.exterior.coords)==5:
>>> print 'Yes, it is a rectangle...'
>>> else:
>>> print 'No, it is not a rectangle...'
>>>
Yes, it is a rectangle...
Код: Выделить всё
>>> #poly2 is actually a rectangle
>>> poly2 = Polygon([(0, 1), (0, 3), (2, 3), (2, 2), (2, 0), (0, 0), (0, 1)])
>>>
>>> poly_check=poly2.simplify(0)
>>> if len(poly_check.exterior.coords)==5:
>>> print 'Yes, it is a rectangle...'
>>> else:
>>> print 'No, it is not a rectangle...'
>>>
No, it is not a rectangle...
Спасибо
Подробнее здесь: https://stackoverflow.com/questions/624 ... -rectangle