I need to get a convex_hull of a polygon. I'm using shapely. Nt sure how to apply convex_hull to get the result I need:
from shapely.geometry import Polygon
p = Polygon(((0,0),(2,0),(2,2),(0,2),(1,1)))
The result I need. I don't know how to get the coordingates including repeating the first:
In[]: p.convex_hull # How to get the resulted coordinates?
Out[]:
((0,0),(2,0),(2,2),(0,2),(0,0)
Try this:
from shapely.geometry import Polygon
p = Polygon(((0,0),(2,0),(2,2),(0,2),(1,1)))
x = p.convex_hull
a, b = x.exterior.coords.xy
tuple(list(zip(a,b)))
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.