I am working in a Python notebook within ArcGIS Pro. I am clipping rasters to the extent of a shapefile, then averaging the resulting rasters into one. From there I am trying to use zonal statistics on a set of bands from that processed raster to average out the values in the raster per census tract (so that the raster has the same value across the entire tract). Whenever I run the zonal statistics tool, it gives me an error saying the files don't exist. I've checked the directory (temp directory because I don't want a ton of layers being added to the map for management reasons) and the files are indeed not there, but I stored them in a list and I can access and show them from the list, so they are being stored, but I guess are being deleted immediately from the directory. What is weird to me is that if I do the same thing, but use the preprocessed, clipped rasters instead of the averaged one, the files are saved in the temp directory and the tool runs fine.
This works fine
clipped_rasters245 = []
for raster in rasters245:
temp_clip = arcpy.ia.Clip(raster,aoi=r'C:\Users\guilh\Downloads\OneDrive_3_8-23-2023\SABR.shp')
clipped_rasters245.append(temp_clip)
cur_band=clipped_rasters245[1].bands()[0]
new_raster245 = arcpy.sa.ZonalStatistics(tracts,'FIPS',cur_band,'MEAN')
While this does not work because the files (when calling the bands function) don't exist
mean_raster245= arcpy.ia.Mean(clipped_rasters245,extent_type='IntersectionOf',
cellsize_type='MeanOf',
ignore_nodata = True
)
cur_band= mean_raster245.bands()[0]
new_raster245 = arcpy.sa.ZonalStatistics(tracts,'FIPS',cur_band,'MEAN')