49

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?

Georgy
  • 12,464
  • 7
  • 65
  • 73
Valeria
  • 1,508
  • 4
  • 20
  • 44

1 Answers1

84

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)
Georgy
  • 12,464
  • 7
  • 65
  • 73
ewcz
  • 12,819
  • 1
  • 25
  • 47