I think this blog post follows up nicely to Dan Patterson's recent blog post, ...That empty feeling... The conversation about null and empty geometries in ArcGIS isn't new, but it does take some getting your head around.
When it comes to creating new feature classes, I am sure most people are quite familiar with the following screen from the New Feature Class wizard:
When creating a new feature class using ArcGIS Desktop, either through the GUI or ArcPy, the default settings allow for NULL values in the SHAPE field (see yellow highlight above). Regardless of whether NULLs in the SHAPE field are a good or bad idea, they are supported and allowed by default, so it is good to understand what does/can happen when geometries aren't populated with the rest of a record in feature classes.
After troubleshooting several cases where NULL wasn't NULL, I decided to take a deeper look at what really happens when geometries aren't populated in feature classes. It turns out, the answer depends both on the tool and type of geodatabase being used to insert, store, and retrieve records. Presented here are the results for some of the more common tools and types of geodatabases.
Table 1 shows what actually gets populated in the SHAPE field when nothing, None, an empty geometry, and a non-empty geometry are inserted into a polygon feature class using three different methods.
TABLE 1: SHAPE Field Values in Feature Class | |||||
Storage Type | Insert Method | NOTHING | NONE | EMPTY | POLYGON |
---|---|---|---|---|---|
PGDB | ArcMap Editor | Null | N/A | N/A | Polygon |
PGDB | arcpy.InsertCursor | Null | Error | Empty | Polygon |
PGDB | arcpy.da.InsertCursor | Null | Null | Null | Polygon |
FGDB | ArcMap Editor | Empty | N/A | N/A | Polygon |
FGDB | arcpy.InsertCursor | Null | Error | Empty | Polygon |
FGDB | arcpy.da.InsertCursor | Null | Null | Null | Polygon |
SDE(SQL) | ArcMap Editor | Empty | N/A | N/A | Polygon |
SDE(SQL) | arcpy.InsertCursor | Null | Error | Empty | Polygon |
SDE(SQL) | arcpy.da.InsertCursor | Null | Null | Null | Polygon |
SDE(ORA) | ArcMap Editor | Empty | N/A | N/A | Polygon |
SDE(ORA) | arcpy.InsertCursor | Null | Error | Empty | Polygon |
SDE(ORA) | arcpy.da.InsertCursor | Null | Null | Null | Polygon |
NOTE:
|
Table 2 shows what gets returned by search cursors once the records from Table 1 have been inserted into a feature class.
Table 2: Retrieved Geometry/Object From SHAPE Field | ||||
Storage Type | Retrieve Method | NULL | EMPTY | POLYGON |
---|---|---|---|---|
PGDB | arcpy.SearchCursor | None | Empty | Polygon |
PGDB | arcpy.da.SearchCursor | None | None | Polygon |
FGDB | arcpy.SearchCursor | None | Empty | Polygon |
FGDB | arcpy.da.SearchCursor | None | None | Polygon |
SDE(SQL) | arcpy.SearchCursor | None | Empty | Polygon |
SDE(SQL) | arcpy.da.SearchCursor | None | None | Polygon |
SDE(ORA) | arcpy.SearchCursor | None | Empty | Polygon |
SDE(ORA) | arcpy.da.SearchCursor | None | None | Polygon |
NOTE:
|
It is clear there are some differences, inconsistencies one might say, with how different tools insert nothing or empty geometries into a feature class that allows NULL values. Even with the same tool, there are situations where nothing or empty geometries are handled differently between different types of geodatabases. There are also differences with how different search cursors, and likely update cursors, retrieve empty geometries from feature classes.
I can't say what it all means, but there are a few items that stuck out for me.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.