I am trying to perform zonal statistics on a single band from a multi-band raster in .pix format.
I have things working great with a tiff file. I am able to access the bands using this code:
desc = arcpy.Describe(inRaster) for band in desc.children: bandName = band.name currentBand = inRaster + "\\" + bandName
And then just using bandName as the input raster.
However, this code does not work with my .pix file ("Input value raster: testraster.pix\b does not exist.")
I think I can use the CopyRaster tool to convert the file to tiff format, but this is slow and seems like it should be unnecessary.
Does anyone know if there is an easier/more efficient way?
I've also tried the MakeRasterLayer tool to make a raster layer from a single band. I first tried this in ModelBuilder and it worked great. I extracted the ModelBuilder code to python to ensure I was running it with the exact same parameters, but alas, I get the following error:
ExecuteError: ERROR 010213: Error in reading raster band1. Zonal statistics program failed ERROR 010067: Error in executing grid expression. Failed to execute (ZonalStatisticsAsTable).
This is when using the exact same input files and the same tool, so I'm not quite sure why it isn't working.
I've also tried GDAL, but I'm not sure if it's possible to load a raster with GDAL and then process it with arcpy. Here is part of my code:
filename = "E:\\Temp\\Test\\testraster.pix" dataset = gdal.Open( filename, GA_ReadOnly ) band = dataset.GetRasterBand(1) outStats = ZonalStatisticsAsTable(shapeFile, shapeFileField, band, outTable, "DATA", "MEAN")
Which results in (as I expected):
RuntimeError: Object: Error in executing tool