Another consequence of the geometry objects becoming immutable is that assigning custom attributes, which currently works, will no longer be possible.
几何对象变得不可改变的另一个后果是,目前的自定义属性也将不再可用。
Currently you can do:
目前能做的是:
>>> line.name = "my_geometry"
>>> line.name
'my_geometry'
In Shapely 1.8, this will start raising a warning, and will raise an AttributeError in Shapely 2.0.
在Shapely 1.8中,这将开始引发警告,而在Shapely 2.0中会引发AttributeError。
How do I update my code? There is no direct alternative for adding custom attributes to geometry objects. You can use other Python data structures such as (GeoJSON-like) dictionaries or GeoPandas’ GeoDataFrames to store attributes alongside geometry features.
我怎样才能更新我的代码?对于向几何对象添加自定义属性,没有直接的替代方法。你可以使用其他的Python数据结构,如(类似于GeoJSON的)字典或GeoPandas的GeoDataFrames来存储几何对象的属性。