我有一个wkt格式的MultiPolygon列表,我必须从这些点获取坐标。
有人能帮帮我吗?提前感谢
发布于 2021-10-04 14:26:38
您可以使用修长 Python模块解析WKT几何并提取坐标。
尝试如下:
import shapely.wkt
shapes = [ 'MULTIPOLYGON (((69.0 41.0, 69.0 41.4, 69.4 41.4, 69.4 41.0, 69.0 41.0)), ((59.0 42.0, 59.0 42.4, 59.4 42.4, 59.4 42.0, 59.0 42.0)))' ]
for shape in shapes:
shapelyObject = shapely.wkt.loads(shape)
for polygon in shapelyObject:
coords = list(polygon.exterior.coords)
print(coords)输出:
[(69.0, 41.0), (69.0, 41.4), (69.4, 41.4), (69.4, 41.0), (69.0, 41.0)]
[(59.0, 42.0), (59.0, 42.4), (59.4, 42.4), (59.4, 42.0), (59.0, 42.0)]https://stackoverflow.com/questions/69437531
复制相似问题