Select to view content in your preferred language

Need to Drop Band 4 from a 4 Band TIF

16516
12
07-15-2010 03:57 PM
RandyKreuziger
Frequent Contributor
I need to load some new 2009 4-band NAIP data into SDE to support ArcIMS applications.  We don't have enough space to hold the 4-band data but we do if the IR 4th band is dropped.  I need to do this for a few thousand TIFs.
0 Kudos
12 Replies
JohnSobetzer
Honored Contributor
If you use a program like Irfanview (free) and save to tif. it should drop the 4th band.  It has a batch conversion function.  There may be other image viewers or editors that also have the batch function and most probably drop that 4th band.
0 Kudos
RandyKreuziger
Frequent Contributor
I'm hoping for an geoprocessing solution.  The data is on an external hard drive and needs to remain intact.  There is not enought disk space to hold a copy of the data.  So what I want to do is copy a TIF to the network, drop band 4 and then import into SDE.
0 Kudos
GünterDörffel
Frequent Contributor
Hi Randy,

are we talking ArcGIS 10?

If so, you could first define a MosaikDatset from your 4band tifs - but only use the 3 bands you want to use. Mosaiks support this either while importing or later on the MosaicDataset Level by using an ExtractBands dynamic function ... then you could load the data into SDE from the Mosaic - if you still want to do that ...

Give it a try - its time to get used to the power of MosaicDatsets anyway 😄

Regards
Guenter
0 Kudos
MelanieHarlow
Esri Contributor
You could create a model that uses the Make Raster Layer tool and then the Copy Raster tool to remove the 4th band.
The Make Raster Layer tool allows you to specify the input bands. In your case, 1,2,3.
RandyKreuziger
Frequent Contributor
ESRI support came through for me once I did the technical request.  It was there all the time and I missed it.  Composite Bands (Data Management) does the trick.  Just add the bands you want instead of the raster file.
AARONHOSFORD
Emerging Contributor
You could create a model that uses the Make Raster Layer tool and then the Copy Raster tool to remove the 4th band.
The Make Raster Layer tool allows you to specify the input bands. In your case, 1,2,3.


Is there a way to batch process this and maintain the original raster name?  I have 1000+ images that need to drop the 4th band and be saved in a different location.  I am going from raster.tif to raster.tif in another location.  I have been trying to get the raster iterator to work but i cannot get it to maintain the original file name.  Script or model, either way it works, will work for me.  Thank you.
0 Kudos
RandyKreuziger
Frequent Contributor
I have been trying to get the raster iterator to work but i cannot get it to maintain the original file name.  Script or model, either way it works, will work for me.


I wrote the following 2 and a half years ago so you'll want to it to arcpy.  It retains the name of the original TIF but saves it to a different folder.


# Import system modules
import sys, string, os, arcgisscripting

# Create the Geoprocessor object
gp = arcgisscripting.create()

# Load required toolboxes...
gp.AddToolbox("C:/\Program Files (x86)/ArcGIS/ArcToolbox/Toolboxes/Data Management Tools.tbx")

gp.workspace = "E:/Temp/FourBandNAIP"

tifList = gp.ListRasters("*")
inTIFF = tifList.Next()
while inTIFF:
    outTIFF = "E:/Rasters/NAIP2009/" + inTIFF
    if gp.exists(outTIFF):
        print "Skipping " + str(inTIFF)
    else:
        # Create a value table to hold the multivalue parameters for the Union_analysis
        vtab = gp.CreateObject("ValueTable")  
        vtab.AddRow(inTIFF + "\\Band_1")
        vtab.AddRow(inTIFF + "\\Band_2")
        vtab.AddRow(inTIFF + "\\Band_3")
        # Process: Composite Bands...
        print "Composite Bands 1 2 3 " + str(inTIFF)
        gp.CompositeBands_management(vtab, outTIFF)    
    inTIFF = tifList.Next()

del gp
0 Kudos
AARONHOSFORD
Emerging Contributor
I believe i have it in arcpy format:
[ATTACH=CONFIG]30671[/ATTACH]
I am a novice at this though, so here is what is happening:

i am getting an error which states:

[ATTACH=CONFIG]30672[/ATTACH]

I have tried looking this up and using the RasterList page in Resources but it is not helping. Thanks a ton.
0 Kudos
RandyKreuziger
Frequent Contributor
Change the while loop into a for loop and it should work.
0 Kudos