1

在 Python 2.7 和 windows 7 机器(64 位)上。Shapely 模块 v. 1.2.16

该错误似乎与PyScripter IDE的使用有关。我在 Python shell 上尝试了以下代码,代码运行良好

from shapely.geometry import Polygon

p1 = Polygon([(0, 1), (1, 1), (1, 0), (0, 0), (0, 1)])
p2 = Polygon([(2, 4), (4, 4), (4, 2), (2, 2), (2, 4)])
p3 = Polygon([(0, 3), (3, 3), (3, 0), (0, 0), (0, 3)])


>>> p1.intersects(p2)
False
>>> p1.intersection(p2).area
0.0

>>> p1.intersects(p3)
True
>>> p3.intersection(p1).area
1.0

>>> p3.intersects(p2)
True
>>> p3.intersection(p2).area
Traceback (most recent call last):
  File "<interactive input>", line 1, in <module>
  File "C:\Python27\lib\site-packages\shapely\geometry\base.py", line 366, in intersection
    return geom_factory(self.impl['intersection'](self, other))
  File "C:\Python27\lib\site-packages\shapely\topology.py", line 43, in __call__
    product = self.fn(this._geom, other._geom, *args)
WindowsError: exception: float invalid operation
4

0 回答 0