Skip to main content
Bumped by Community user
Bumped by Community user
Bumped by Community user
Bumped by Community user
edited tags
Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345
added 469 characters in body
Source Link
BruceDoh
  • 511
  • 2
  • 13

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

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 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
deleted 40 characters in body; edited tags
Source Link
PolyGeo
  • 65.4k
  • 29
  • 114
  • 345

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?

Thanks for any suggestions.

UPDATE: I'veI'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 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?

Thanks for any suggestions.

UPDATE: 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 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.

added 600 characters in body
Source Link
BruceDoh
  • 511
  • 2
  • 13
Loading
Source Link
BruceDoh
  • 511
  • 2
  • 13
Loading