For some reason, SelectLayerByLocation_management
is not filtering with arcgispro-py3 instances from ArcGIS Pro 2.8 and ArcGIS Server 10.9. Filtering works fine using ArcGIS Server 10.9 python2.7 installation. The mosaic dataset has about 280K rasters and the AOI polygon should only return a subset of matching OIDs based on intersect with the Mosaic Dataset footprint layer. I tried setting arcpy.env.outputCoordinateSystem
to the MD SR (4326) before calling SelectLayerByLocation_management
but that didn't work. Am I missing something?
import arcpy
path_md = r'H:/Data/Raster.gdb/MD1'
path_aoi_geojson = r'H:/Data/aoi.json'
PATHS = r'in_memory\paths'
with open(path_aoi_geojson) as f:
geojson = json.loads(f.read())
ft = geojson['features'][0]
path_aoi = arcpy.AsShape(ft['geometry'], False)
arcpy.MakeMosaicLayer_management(path_md, 'MD_Lyr')
arcpy.SelectLayerByLocation_management(r'MD_Lyr\Footprint', 'INTERSECT', path_aoi)
oid_list = set(row[0] for row in arcpy.da.TableToNumPyArray(r'MD_Lyr\Footprint' ,"OID@"))
print(str(len(oid_list))