To convert a Shapely polygon to an Esri polygon using ArcPy, you can follow these steps:
-
Create a Shapely Polygon:
- First, create your desired Shapely polygon using the Shapely library in Python.
-
Convert to Esri Polygon:
- Use the
arcpy.FromWKB()
function to convert the Shapely polygon’s WKB (Well-Known Binary) representation to an Esri polygon. - Example:
from shapely.geometry import Polygon import arcpy # Create a Shapely polygon shapely_polygon = Polygon([(0, 0), (1, 0), (1, 1), (0, 1)]) # Convert to Esri polygon esri_polygon = arcpy.FromWKB(shapely_polygon.wkb) # Now you can use 'esri_polygon' in your ArcPy workflows
- Use the
-
Write to a Feature Class:
- You can write the Esri polygon to a new feature class using an insert cursor.
- Example:
new_fc = r"C:\path\to\your\geodatabase.gdb\NewFeatureClass" with arcpy.da.InsertCursor(new_fc, ["SHAPE@"]) as cursor: cursor.insertRow([esri_polygon])
Remember to adjust the code according to your specific Shapely polygon and desired feature class. Let me know if you need further assistance!
标签:Convert,Polygon,polygon,Shapely,using,your,Esri From: https://www.cnblogs.com/alex-bn-lee/p/18241792