Given that ArcPy is a Python site package, the ArcPy geometries should actually be Pythonic. What do I mean by Pythonic? ArcPy geometries and components should be accessible and modifiable using standard Python conventions like iterating, indexing, and slicing among others. The idea isn't original; in fact, Pythonic geometries have already been implemented in GeoDjango (Geometries are Pythonic).
Constructing empty geometries isn't possible using the ArcPy Geometry classes. The only way to currently create an empty geometry in ArcPy is to use the arcpy.FromWKT as a geometry constructor. I propose the ArcPy Geometry classes support the construction of empty geometries.
Currently, calling any of the ArcPy Geometry constructors with no arguments, a 'None' argument, or an empty arcpy.Array throws an exception.
>>> arcpy.Polygon() Runtime error Traceback (most recent call last): File "<string>", line 1, in <module> File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\arcobjects\mixins.py", line 222, in __init__ *gp_fixargs(args, True)) File "c:\program files (x86)\arcgis\desktop10.3\arcpy\arcpy\geoprocessing\_base.py", line 504, in <lambda> return lambda *args: val(*gp_fixargs(args, True)) RuntimeError: Object: CreateObject cannot create geometry from inputs
Instead, the constructors should generate an empty geometry of the appropriate type similar to geometry constructors from other Python (Shapely) and DBMS (SQL Server) packages.
>>> pg = arcpy.Polygon() >>> pg.type u'polygon' >>> pg.WKT u'MULTIPOLYGON EMPTY'
This is looking good for implementation, although the feedback isn't clear whether that will be in an upcoming minor or major release.
Another great python Geometry implementation that I've worked with is Geoalchemy2.
GeoAlchemy 2 Documentation — GeoAlchemy2 0.3.0 documentation
Given empty geometries are actually/already supported by the geometry constructors, I think this idea should be merged with https://community.esri.com/ideas/10963 since what I am after is having the syntax for creating empty geometries be more intuitive and idiomatic.
An example of making ArcPy Geometry constructors more Pythonic: /blogs/tilting/2017/06/12/a-case-for-no-argument-arcpy-geometry-constructors?sr=search&searchId=c932....
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.