Extract points/coordinates from a polygon in Shapely

The trick is to use a combination of the Polygon class methods:

from shapely.geometry import Polygon

# Create polygon from lists of points
x = [0.0, 0.0, 1.0, 1.0, 0.0]
y = [0.0, 1.0, 1.0, 0.0, 0.0]

poly = Polygon(zip(x,y))

# Extract the point values that define the perimeter of the polygon
xx, yy = poly.exterior.coords.xy

# Note above return values are of type `array.array` 
assert x == xx.tolist()
assert y == yy.tolist()

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)