Select to view content in your preferred language

CompositeBands_management invalid ext

2734
4
09-24-2010 10:42 AM
PaulSowers
Deactivated User
I am trying to use the CompositeBands_management function in a python script and am encountering an error that doesn't make sense to me.

I am using the following command:
gp.CompositeBands_management("L71029027_02719990831_B10.TIF;L71029027_02719990831_B20.TIF;L71029027_02719990831_B30.TIF","C:/L7029027_02719990831.tif")

Error code:
ERROR 000445: Extension is invalid for the output raster format.
Failed to execute (CompositeBands).


According to the documentation I have been able to find, TIFF format seems to be supported for this function and '.tif' is the required file extension.  I have tried switching case and removing the absolute paths but have had no joy. I am at a loss and would appreciate any help you could lend.

Thanks!

The python code looks like:
import arcgisscripting as Arc
gp = Arc.create()
f = lambda x: '"' + x + '"'
bands = f(bands.rstrip(';')) 
composite = f(os.path.join(outpath, composite)) 
gp.workspace = f(os.path.abspath(tmpdir))
gp.CompositeBands_management(bands,composite)
0 Kudos
4 Replies
JieZhang
Esri Contributor
Hi, Paul

You are correct, writing to TIFF is supported and ".tif" is the right extension. Your code pasted here seems to be OK. And it is indeed quite strange for you to see this error message.

However I have gone through the same workflow as you did, but could not get the same error.

You may want to check two things here:

1. Before you call the tool, have a print statement to check whether the "bands" and "composite" variables have the correct value.

2. After you run the tool, print out the message with "gp.getmessages()" to see if the tool runs with the correct settings.

e.g. something like: CompositeBands h:\10UCDemoData\Data\Columbia_River\Landsat\LE70430272002285EDC00\L71043027_02720021012_B10.TIF;h:\10UCDemoData\Data\Columbia_River\Landsat\LE70430272002285EDC00\L71043027_02720021012_B20.TIF C:\L71043027_02720021012.tif


If all these information seems to be correct, may I ask which version of ArcGIS you are using here?

Thanks
Jie
0 Kudos
PaulSowers
Deactivated User
2. After you run the tool, print out the message with "gp.getmessages()" to see if the tool runs with the correct settings.
Before:
gp.CompositeBands_management("C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B10.TIF;C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B20.TIF;C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B30.TIF","C:\_WorkSpace\testout\L7029027_02719990831.tif")

Executing: CompositeBands C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B10.TIF;C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B20.TIF;C:\_WorkSpace\tmpe2vzhq\L71029027_02719990831_B30.TIF "C:\_WorkSpace\testout\L7029027_02719990831.tif"
Start Time: Mon Sep 27 08:47:58 2010
Failed to execute. Parameters are not valid.
ERROR 000445: Extension is invalid for the output raster format.
Failed to execute (CompositeBands).
End Time: Mon Sep 27 10:47:58 2010 (Elapsed Time: 0.00 seconds)

Thanks for your response Jie.
The gp.getmessages() command helped.

I had printed the variables before sending them to gp.CompositeBands_management() command and everything was correct but gp.getmessages() showed that the function was removing the quotes from the input bands but not the output image.  After removing the quotes I stopped getting the error, kinda strange but it seemed to fix that problem!

However, now the script never closes, it hangs during the composite bands command. I know it executes because the output file gets created and is 190KB, though I get an error when trying to open it ('Invalid or unsupported TIFF file').  

My python code hasn't changed from my original post, other than to not quote the output (composite) dataset.

Also,  I am using ArcGIS 9.3.1 ArcInfo

Thanks again for your help!
0 Kudos
JieZhang
Esri Contributor
Hi Paul,

You are welcome. I am glad we are moving forward here.

According to your description, it seems the tool is working correctly but taking long time (or never) to finish? I have noticed that you are working with Landsat 7 data. It could take a while to finish since the composite image could be about 1GB. And if each band does not have pyramids, the tool will also spend time in building pyramids. You may want to wait a bit longer.

If the process really hangs, you may want to check first that the data is not corrupted (for example, you can add each band image to ArcMap), then you can check whether the tool works by going to the toolbox and use the composite bands tool in Raster Processing toolset through UI.

If even using the tool hangs, then we might have a problem here with this specific dataset. Is it possible that you share the download link to the data? Or you may want to contact Support, so that we can get your data and reproduce the problem on our end.

Let me know if this helps.

Jie
0 Kudos
PaulSowers
Deactivated User
Hey Jie,

You are correct I am working with Landsat 7 data and I believe the tool to be truly hanging up.  I let the script run in the background for over an hour, but nothing ever happened (after the first minute or so the file size never changed).  Also, after encountering this problem I ran just the compositebands function from the ArcMap command line and it too hung up.  The progress bar quickly progressed to about 75% then stopped, it too ran in the background for about an hour.

I don't believe the input images to be corrupt,  I have loaded them in ArcMap without error.  However, every time I am working with a new set of images (my script extracts the bands I am interested in from a tar file to a temp folder, which will be deleted after the composite image is created).

All is not lost, however, I decided to try creating an Imagine format image rather than a TIFF.  The script completed successfully very quickly and the output composite .img file opens successfully in ArcMap and Imagine and contains the spatial reference and pyramid layers as well.

Output format isn't terribly important to me so I am declaring success.

Thank you again for your help and your quick responses.

p.s.  I don't have the link to the original landsat images, I got them from a local server and am only using them to put this script together.
0 Kudos