Select to view content in your preferred language

Extract single bands from ECW image using Arcpy

825
3
05-30-2019 04:07 AM
AnthonyCheesman1
Frequent Contributor

Hi folks

ive also asked this over at the Spatial Analyst group with no response, so I thought I’d try here.

im looking for a Pythonic way to extract a single band from a multi band ECW image. The ECW part is important, as every time I try to run an ArcToolbox tool on the data, Arcmap immediately crashes. I get the same result using IDLE and arcpy. The only success I’ve had on the Desktop front was by loading the specific band, and then right clicking > Export Data.

the one bit of success I had was creating a faster object using arcpy.sa.Raster and then saving this to a different workspace. However this copied all bands over, not just the band I had selected for the raster object. (path/image.ecw/Red for example).

Why am I doing this? I need to be able to batch generate a heap of NDVI outputs, where I need to extract the red band from the VIS image and the IR band from the IR image. 

Any my suggestions will be gratefully appreciated.

Thanks

Ant

Tags (3)
0 Kudos
3 Replies
DanPatterson_Retired
MVP Emeritus

what version of ArcMap? or is it ArcGIS Pro you are using.  Non-English characters? particular locale?

I ask because

BUG-000110931: Unable to load Enhanced Compression Wavelet (ECW) fi.. 

plus a load more in the last year

ECW bug list for the last year

0 Kudos
AnthonyCheesman1
Frequent Contributor

Hi Dan

I’ve had the same issue with 10.3.1 and 10.5.1Australia, en-au. No non-English characters.

That link above re: 10.6.1 is very interesting, not the least because we are (were?) about to do a system-wide migration to 10.6.1 - that may knock it on the head.

After I posted yesterday evening, I got to thinking about any other libraries that may be able to assist, and had a hunt around. It looks as though GDAL should be able to open the images and extract the bands, which I could then load as arrays in numpy to do the required algebra for the NDVI analysis. I haven’t tried yet but it sounds like a promising avenue to investigate.

Thanks

Anthony

0 Kudos
DanPatterson_Retired
MVP Emeritus

Anthony, gdal is within the esri anaconda distribution of ArcGIS Pro... check to see if it is there for ArcMap.  Just about everbody uses it at some level

0 Kudos