EDIT: as requested, here is the top part of the button's code immed after def onClick(self)
mxd = arcpy.mapping.MapDocument("CURRENT")
# 0. VERIFY THAT THE REQUIRED LAYERS ARE PRESENT IN THE MXD.
print
layersPresent = []
for lyr in arcpy.mapping.ListLayers(mxd):
layersPresent.append(lyr.name)
for lyrReqd in (WRS_layer, progressLayerName):
if not lyrReqd in layersPresent:
Error = True
print "ERROR: cannot find layer ", lyrReqd, " in the TOC."
# 1. GET THE SELECTED GRID CELL
d = arcpy.Describe(progressLayerName)
if len(d.FIDSet) == 0:
ProgressGrid_Select = 0
else:
ProgressGrid_Select = len(d.FIDSet.split(";"))
if ProgressGrid_Select <> 1:
print " You have", str(ProgressGrid_Select), " ProgressGrid cells selected -- should be exactly 1."
Error = True
# 2. GET THE INTERSECTING WRS SCENES
# make a WRS list of lists, with PathRow
if not Error:
# SelectLayerByLocation HONOURS THE SELECTION SET IN in_layer
print 'DEBUG: attempting SelectLayerByLocation_management(WRS_layer, "INTERSECT", progressLayerName, "", "NEW_SELECTION")'
arcpy.SelectLayerByLocation_management(WRS_layer, "INTERSECT", progressLayerName, "", "NEW_SELECTION")
# make list of WRS scenes, with PR (data type Long)
WRS_scenes = []
# SearchCursor (in_table, field_names, {where_clause}, {spatial_reference}, {explode_to_points}, {sql_clause})
with arcpy.da.SearchCursor(WRS_layer,WRS_fields) as cursor:
for row in cursor:
WRS_scenes.append(row[0])
if len(WRS_scenes) == 0:
print "No WRS_scenes intersect with selected Progress Grid cell."
Error = True
else:
print "Found " + str(len(WRS_scenes)) + " WRS scenes for selected progress cell:"
WRS_scenes.sort()
prs = ''
for pr in WRS_scenes:
prs += (" " + str(pr))
print prs
print