In a separate question (Create NIL (zero vertex) geometry), @DanPatterson mentioned:
I can only wish points could just be defined from arrays
np.full(shape=(4,), fill_value=np.nan, order='C')
array([nan, nan, nan, nan])
# -- or
np.empty((0,))
array([], dtype=float64)
ArcPy isn't my area of expertise. But it seems like an interesting idea. Could ArcPy be enhanced so that points can be defined from arrays?
Dan, feel free to clarify.
@Bud , you sort of can. I create a polygon from four lat./long. coordinates. I collect four sets of coordinates from emails for marking utilities. I think that the array is actually a list, but in this instance it works like an array. After this portion of code, I use an UpdateCursor to add attributes to the new polygon in a feature-class. FYI, I'm still on Pro 2.9, so I'm using arcpy version 2.
fc = r"C:\myPython.gdb\AZ811_BlueStake"
iCursor = arcpy.da.InsertCursor(fc, ["SHAPE@"])
array = arcpy.Array([arcpy.Point(lonX_NW, latY_NW),
arcpy.Point(lonX_NE, latY_NE),
arcpy.Point(lonX_SE, latY_SE),
arcpy.Point(lonX_SW, latY_SW)])
# Spatial reference set to GCS_WGS_1984
spatial_reference = arcpy.SpatialReference(4326)
polygon = arcpy.Polygon(array, spatial_reference)
iCursor.insertRow([polygon])
del iCursor
It is the excessive arcpy.Point to create an arcpy.Array. It has few properties and methods that can't be handled with an array (of some type, eg numpy, etc) of doubles. Everything in geometry goes back to arcobjects, which has been written a long time ago and making serious changes would be highly unlikely.
There is always the arcgis module, or roll out your own geometry module to interface with arcpy, as I did.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.