Geometry objects will become immutable in version 2.0.0.
在2.0.0版本中,几何对象将成不可变。
In Shapely 1.x, some of the geometry classes are mutable, meaning that you can change their coordinates in-place. Illustrative code:
在Shapely 1.x中,一些几何对象是可变的,这意味着你可以就地改变其坐标。示例代码如下:
>>> from shapely.geometry import LineString
>>> line = LineString([(0,0), (2, 2)])
>>> print(line)
LINESTRING (0 0, 2 2)
>>> line.coords = [(0, 0), (10, 0), (10, 10)]
>>> print(line)
LINESTRING (0 0, 10 0, 10 10)
In Shapely 1.8, this will start raising a warning:
在Shapely 1.8中,这会引发一个警告。
>>> line.coords = [(0, 0), (10, 0), (10, 10)]
ShapelyDeprecationWarning: Setting the 'coords' to mutate a Geometry
in place is deprecated, and will not be possible any more in Shapely 2.0
and starting with version 2.0.0, all geometry objects will become immutable. As a consequence, they will also become hashable and therefore usable as, for example, dictionary keys.
从2.0.0版本开始,所有的几何对象将变得不可改变。因此,它们也将变成可哈希,因此可以作为字典的键值使用。
How do I update my code? There is no direct alternative for mutating the coordinates of an existing geometry, except for creating a new geometry object with the new coordinates.
我怎样才能更新我的代码?除了用新的坐标创建一个新的几何对象外,没有其他直接的办法来改变现有的几何对象的坐标。