Reputation: 23
I have a list of polygon objects:
[shapely.geometry.polygon.Polygon object at 0x7efa3099f210,
shapely.geometry.polygon.Polygon object at 0x7efa3099f5d0,
shapely.geometry.polygon.Polygon object at 0x7efa30a01410]
I would like to convert these back into a list of 2D coordinates like this:
[[(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)]]
I realize from shapely.geometry import Polygon converts the coordinates into a polygon, however I am trying to do the opposite.
Any advice on how to go about this using Python?
Upvotes: 0
Views: 1533
Reputation: 8572
I'm not sure on API, but try
coords = [list(poly.exterior.coords) for poly in poly_list]
Upvotes: 1