如何使用Python将多边形对象列表转换为2D坐标列表

时间:2019-02-11 14:17:54

标签: python list polygon points

我有一个多边形对象列表:

[shapely.geometry.polygon.Polygon object at 0x7efa3099f210, 
 shapely.geometry.polygon.Polygon object at 0x7efa3099f5d0, 
 shapely.geometry.polygon.Polygon object at 0x7efa30a01410]

我想将它们转换回2D坐标列表,如下所示:

[[(59.019498746806114, -45.665396889176236), 
  (59.94899586119081, -45.18051792326192), 
  (60.264519944473435, -43.49720173548366), 
  (63.13914992079595, -41.75713765132456)], 
 [(65.27046115508618, -38.81009751714569), 
  (66.87400474798349, -35.32763756915183), 
  (66.59651348548812, -34.479633238363796), 
  (64.08620000264494, -34.508862817833695)], 
 [(62.967585829885984, -39.02682594501325), 
  (58.84847235610258, -41.12579914422148), 
  (57.972105870186965, -45.614782988871184), 
  (59.019498746806114, -45.665396889176236)]]

我从shapely.geometry import认识到Polygon将坐标转换为多边形,但是我试图做相反的事情。

关于如何使用Python进行此操作的任何建议?

1 个答案:

答案 0 :(得分:0)

我不确定使用API​​,但是请尝试

coords = [list(poly.exterior.coords) for poly in poly_list]