I am trying to use the geometry method to calculate the convex hull around two polygons (polyA
, polyB
) with the following code:
# Union both polygons to one (multipart) polygon:
polyAB = polyA.union(polyB)
# Calculating the convex hull around polyAB:
convexhullAB = polyAB.convexHull()
To check if it is working I am writing the combined polygon (polyAB
) and the convex hull (convexhullAB
) to a shapefile:
cur_poly = arcpy.da.InsertCursor("polyAB.shp", ["SHAPE@"])
cur_poly.insertRow((polyAB,))
cur_convex = arcpy.da.InsertCursor("convex.shp", ["SHAPE@"])
cur_convex.insertRow((convexhullAB,))
The shapefile polyAB.shp
contains the (correct) polygon, but convex.shp
is empty.
Has anyone an idea what went wrong?
convexhullAB = polyAB.convexHull()
, tryconvexhullAB.getPart()
. If it gives you array of coordinates (expecting to see more than 3 coordinates), that means you have your convex hull. Lastly, tryarcpy.CopyFeatures_management(convexhullAB, "convex_text.shp")
, if it creates a shapefile, then it means your geometry has no issues.