I have a number of point feature classes that are the result of geocoding various types of permits. I have 5 different permit feature classes, and since many of them were issued to same address, they are 'stacked' when viewed on a map. I wrote a simple script that adds and subtracts 5 map units from the SHAPE@X value or the SHAPE@Y value. That works great when all the records in a feature class have values, but since this feature class is the result of geocoding, those records that did not match have <null> values for their coordinates.
As a result, as I UpdateCursor through the feature class records, and try to perform an additive or subtractive operation the script errors out with something to the effect of 'Sorry Joe, I can't add or subtract from None'
Below is an example of the where clause in a SearchCursor:
fields = ['SHAPE@X','SHAPE@Y']
select = 'SHAPE@X is not None'
for fc in arcpy.ListFeatureClasses():
with arcpy.da.SearchCursor(fc,fields,select)as cursor:
for row in cursor:
if fc == 'APLIC':
print(row[0])
Traceback (most recent call last):
File "<ipython-input-16-18ea27620933>", line 3, in <module>
for row in cursor:
RuntimeError: An invalid SQL statement was used. [SELECT OBJECTID,Shape FROM APLIC WHERE SHAPE@X is not None]
I guess I could wrap my cursor in a try/except block block but I'd rather just process those records that have valid values in SHAPE@X and SHAPE@Y . Is there a way to select for just those records that meet my criteria?