Advertisement
Guest User

Untitled

a guest
Jun 24th, 2019
70
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.55 KB | None | 0 0
  1. #### firstly, import Polygon class ####
  2. from shapely.geometry import MultiPolygon, Polygon
  3. .
  4. .
  5. .
  6. # make polygon
  7. thetas = np.linspace(0, 2 * np.pi, 360)
  8. polygon_x = x[:,None] + r[:,None] * np.sin(thetas)
  9. polygon_y = y[:,None] + r[:,None] * np.cos(thetas)
  10.  
  11. # list of convex hulls of subsequent circles
  12. ps = [Polygon(i) for i in np.dstack((polygon_x, polygon_y))]
  13.  
  14. # list of convex hulls of subsequent circles
  15. n = range(len(ps)-1)
  16. convex_hulls = [MultiPolygon([ps[i], ps[i+1]]).convex_hull for i in n]
  17.  
  18. # Final polygon
  19. polygons = cascaded_union(convex_hulls)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement