Use arcpy to extract bands from ECW image

891
1
05-29-2019 09:51 PM
AnthonyCheesman1
Occasional Contributor II

Hi folks


This may be more of an arcpy question than an SA question, but I'll ask anyway.

I'm looking for an automated way using arcpy to extract bands from ECW images. The only way I've been able to do this so far is to do it manually by loading the individual band to an ArcMap session, and then right-click > Export Data. I haven't been able to work out how to do this with any ArcToolbox tools, or any arcpy functions.

Have you been able to do this with arcpy or ArcToolbox in the past? How did you do it?

Thanks

Anthony

0 Kudos
1 Reply
MehdiPira1
Esri Contributor

Anthony Cheesman

Let's say your image contains 3 bands, you can use the following model:

I also wrote a python code for this:

import arcpy
import os
arcpy.env.workspace = r" "
rasterfile = Input Raster
desc = arcpy.Describe(rasterfile)
for band in range (1, desc.bandCount+1):
       outputRaster = "rdlayer_" + str(band)
       print(outputRaster)
       arcpy.management.MakeRasterLayer(rasterfile, outputRaster, '', envelope="", band_index=str(band))‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍‍

Hope that helps.