import arcpy
sr = arcpy.SpatialReference(4326)
# Create polygon 2 x 2 with LL corner at 0,0...
coords = [[0, 0], [0, 2], [2, 2], [2, 0], [0, 0]]
polygon = arcpy.Polygon(arcpy.Array([arcpy.Point(*a) for a in coords]), sr)
arcpy.CopyFeatures_management(polygon, r"C:\Temp\polygon.shp")
# Create point inside the polygon...
point = arcpy.PointGeometry(arcpy.Point(1, 1), sr)
arcpy.CopyFeatures_management(point, r"C:\Temp\point.shp")
I can quickly create a polygon object using a nested list comprehension statement within the arcpy.Array function and use it as a parameter in the CopyFeatures geoprocessing tool (as shown above).
I can quickly create a feature class with a single point object also shown above, again using the CopyFeatures geoprocessing tool.
Is it possible to create a "point" feature class from the "coords" list variable using a similar nested list comprehension approach?
For example, I tried with the following but obviously something is not right here.
point = arcpy.PointGeometry(arcpy.Array([arcpy.Point(*a) for a in coords[:-1]]), sr)
Just trying to make a quick one-liner without resorting to the arcpy.da.InsertCursor method if possible.