Shapely: Polygon from String?

最后都变了- 提交于 2019-12-21 04:00:24

问题


I have saved string representations of some Shapely Polygons:

'POLYGON ((51.0 3.0, 51.3 3.61, 51.3 3.0, 51.0 3.0))'

Is there some fast way of directly converting it back to the Polygon type? Or do I need to manually parse the strings to create Polygon objects?


回答1:


Shapely can directly parse this:

import shapely.wkt

P = shapely.wkt.loads('POLYGON ((51.0 3.0, 51.3 3.61, 51.3 3.0, 51.0 3.0))')
print(P)


来源:https://stackoverflow.com/questions/51855917/shapely-polygon-from-string

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!