How do you get/extract the points that define a shapely
polygon?
Thanks!
Example of a shapely polygon
from shapely.geometry import Polygon
# Create polygon from lists of points
x = [list of x vals]
y = [list of y vals]
polygon = Polygon(x,y)
How do you get/extract the points that define a shapely
polygon?
Thanks!
Example of a shapely polygon
from shapely.geometry import Polygon
# Create polygon from lists of points
x = [list of x vals]
y = [list of y vals]
polygon = Polygon(x,y)
You can use the shapely
mapping
function:Update (2017-06-09):
As the last answer seems not to work anymore with newest version of shapely, I propose this update.
shapely provides the Numpy array interface (as the doc says: http://toblerity.org/shapely/project.html )
So, let
poly
be a shapely polygon geometry:This command will do the conversion to a numpy array:
Hint:
One must need to give the exterior.coords for a polygon because giving the direct geometry seems not to work either: