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_convex = arcpy.da.InsertCursor("convex.shp", ["SHAPE@"])

The shapefile polyAB.shp contains the (correct) polygon, but convex.shp is empty. Has anyone an idea what went wrong?

closed as off-topic by Vince, Midavalo Oct 12 '16 at 5:07

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions seeking help to debug/write/improve code must include the desired behavior, a specific problem or error and the shortest code necessary to reproduce it in the question itself. Providing a clear problem statement and evidence of a code attempt will help others to help you. See: How to create a Minimal, Complete, and Verifiable example." – Midavalo
If this question can be reworded to fit the rules in the help center, please edit the question.

  • 2
    At the moment the code that you have presented seems insufficient to qualify as a code snippet. I suggest you bolster it by using code to build your polyA and polyB (two rectangles is all you need) at the start of it, and then to include pictures of inputs and expected/observed outputs. – PolyGeo Oct 11 '16 at 21:29
  • 1
    Your code with proper geometries is working just fine. I suspect you may have empty geometries. There are a couple of diagnostics that I can offer. Just after convexhullAB = polyAB.convexHull(), try convexhullAB.getPart(). If it gives you array of coordinates (expecting to see more than 3 coordinates), that means you have your convex hull. Lastly, try arcpy.CopyFeatures_management(convexhullAB, "convex_text.shp"), if it creates a shapefile, then it means your geometry has no issues. – fatih_dur Oct 12 '16 at 0:20
  • If you don't include polygon vertex arrays which exhibit the behavior, you can't clear the reproducibility hurdle necessary to make this answerable. – Vince Oct 12 '16 at 3:45
  • Please edit your question to include a reproducible code snippet as requested by PolyGeo and Vince. – Midavalo Oct 12 '16 at 5:08