Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Shapely: Polygon from String?

Tags:

python

shapely

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?

like image 511
Valeria Avatar asked Aug 15 '18 09:08

Valeria


1 Answers

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) 
like image 50
ewcz Avatar answered Sep 21 '22 00:09

ewcz