我有以下形式的 GeoJSON 输出:
{'type': 'Point', 'coordinates': (0.00027777777777777827, 22.000138888888873)}
如何将“坐标”的值从元组转换为列表,同时保持“类型”不变?
我已经尝试使用 {k: [list(ti) for ti in v] for k, v in geom.items()} as given here其中 geom = geometry.mapping(geometry.Point(x, y))但它没有帮助。
我看到一个错误提示“Float object is not iterable”
我正在使用 shapely 库
请您参考如下方法:
您只能将 'coordinates' 键更改为列表:
geom['coordinates'] = list(geom['coordinates'])
输出:
{'type': 'Point', 'coordinates': [0.00027777777777777827, 22.000138888888873]}
