Shapely 1.8.5 中文文档

  1. 主页
  2. 文档
  3. Shapely 1.8.5 中文文档
  4. Migrating to Shapely 1.8 / 2.0(迁移到Shapely 1.8 / 2.0版本)
  5. Geometry objects will become immutable(几何对象将不可变)
  6. Setting custom attributes(设置自定义属性)

Setting custom attributes(设置自定义属性)

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来存储几何对象的属性。

标签 ,
这篇文章对您有用吗?

我们要如何帮助您?

欢迎留下您的宝贵建议

Please enter your comment!
Please enter your name here