Unable to work with ECW images in Python Script?

4285
4
Jump to solution
08-05-2016 05:28 AM
PeterWilson
Occasional Contributor III

I've writen a Python script that resamples ECW images and at the same time converts the tiles to TiFF images. When I try to run the following script I receive the following error message:

Processing COCT_W34A_23_8cm_2015 raster

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'GpMetadataFunctions, Version=10.3.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86' or one of its dependencies. The system cannot find the file specified.
File name: 'GpMetadataFunctions, Version=10.3.0.0, Culture=neutral, PublicKeyToken=8fc3cc631e44ad86'
   at System.Reflection.Assembly._nLoad(AssemblyName fileName, String codeBase, Evidence assemblySecurity, Assembly locationHint, StackCrawlMark& stackMark, Boolean throwOnFileNotFound, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(AssemblyName assemblyRef, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.InternalLoad(String assemblyString, Evidence assemblySecurity, StackCrawlMark& stackMark, Boolean forIntrospection)
   at System.Reflection.Assembly.Load(String assemblyString)
   at GetManagedType(Char* _assembly, Char* _path, Char* _className)


WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].

Error Message

'''
Created on 05 Aug 2016

Resample and Convert

ECW images to TiFF

@author: PeterW
'''
# import site packages and modules
import arcpy
from pathlib import Path

# set arguments
index_layer = r"E:\Projects\2016\G112502\lyr\SubcatchA.lyr"
output_folder = r"E:\Projects\2016\G112502\CoCT_Imagery\SubCatchA\Tiles"

# set environment variables
arcpy.env.overwriteOutput = True


# create single image from tiles based on index selection
def tiles_to_mosaic(index_layer, output_folder):
    with arcpy.da.SearchCursor(index_layer, ["RasterPath"]) as scur:  # @UndefinedVariable
        for row in scur:
            raster_name = Path(row[0]).stem
            arcpy.AddMessage("Processing {0} raster".format(raster_name))
            out_raster = "{0}\\{1}.tif".format(output_folder, raster_name)
            arcpy.Resample_management(row[0], out_raster, cell_size = 0.32, resampling_type = "NEAREST")

tiles_to_mosaic(index_layer, output_folder)

Python  Script

I've even go so far as to set the input arguments to a single ECW image and the output to the output TiFF image, yet I still receive the same error message. I'm able to run the Resample Tool from ArcMap or ArcCatalog with no error messages. I've tested the following on TiFF images and the script runs successfully.

Any advice in how to resolve the following will be appreciated.

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
PeterWilson
Occasional Contributor III

Hi Dan

Solved it, it seems that the conversion from ECW to TiFF either when resampling or mosaicing the tiles to a new raster only works with Python 32 bit and not Python 64 bit. It runs perfectly under my Python 32 bit. I'd like to find out from ESRI what is the difference when running some of their tools under Python 32 bit vs Python 64 bit and why would it fail under Python 64 bit.

View solution in original post

0 Kudos
4 Replies
PeterWilson
Occasional Contributor III

Just a note:

I'm using ArcGIS 10.3.1 and Python 2.7.8

0 Kudos
DanPatterson_Retired
MVP Emeritus

'assembly binding turned off arcmap'

in Dr Google is full of stuff and even more if you drop the arcmap inclusion

arcobjects - Visual Studio 2015 Error when running ArcMap add-in - Geographic Information Systems St...

You will have to explore Peter... you don't specify what ide you are using or a ton of other things that may be causing that error

0 Kudos
PeterWilson
Occasional Contributor III

Hi Dan

I'm working with eclipse IDE, but as mentioned if the image is TiFF it runs perfectly, it only fails with ECW images, yet it runs from ArcMap and ArcCatalog perfectly. I looked at the following link and still receive the same error message.

0 Kudos
PeterWilson
Occasional Contributor III

Hi Dan

Solved it, it seems that the conversion from ECW to TiFF either when resampling or mosaicing the tiles to a new raster only works with Python 32 bit and not Python 64 bit. It runs perfectly under my Python 32 bit. I'd like to find out from ESRI what is the difference when running some of their tools under Python 32 bit vs Python 64 bit and why would it fail under Python 64 bit.

0 Kudos