I have a script that takes a user-provided lat/long, plots it as a point and performs overlay analysis using arcpy.Intersect_analysis() in order to acquire attributes of interest such as land ownership, county, and township/range. The script works correctly, yet townnship/range has gaps in the state of New Mexico, which will create an output with no geometry or attributes if the point overlays one of these gaps (see hypothetical example in screenshot). enter image description here

The output of arcpy_Intersect_analysis() is used in subsequent code, so I need to account for instances where township/range doesn't exist. Any ideas?

Would some use of a SearchCursor work? If the output of arcpy.Intersect_analysis() was called "temp.shp", could code go something like this?

cursor = arcpy.da.SearchCursor("temp.shp", ["SHAPE@XY"])
for row in cursor:
     if row[0] == None:    do this...
     else:                 do that...

Code above does nothing of course, but if I could check the existence of the output feature's centroid, I'd be able to provide a work-around for instances where township/range is absent at the location of the point.

1 Answer 1


Using arcpy.management.GetCount() checks the number of records in an existing feature class, which allows me to handle cases where township/range doesn't exist at the location of the point.

if arcpy.management.GetCount("temp.shp")[0] == "0":    do this 
else:                                                  do that

Found my answer here: How to check if shapefile is empty using ArcPy?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.