Can you help me to extract a single band image from stacked multiband image. Totally, 260 image has been stacked. When I do to this, it will take a long time. So I'd like to know there is any batch process to extract single band image in ArcGIS, ERDAS or ENVI.
In model builder,
iterating rasters from a workspace,
constructing raster file path and file names
feeding the path into Raster Calculator and extend file names with the desired band ID.
defining an output path
This may help.
Not using Arc or ENVI, but another option is GDAL. You could also use gdal_translate with the -b option. The command would look something like:
gdal_translate -b 1 input.tif output.tif
Where the '1' is the number of the band you want to extract.
The gdal_translate man page has all the other options you may need.
You could reference individual bands in Arcmap 10 by using the full path name and "\Layer_X" where X is the band you want (Eg: "D:\GIS\layerstacks\1993_stack.img\Layer_27"). So if I wanted to save the 27th band from the stacked images, I would write a simple raster calculator statement like
"D:\GIS\layerstacks\1993_stack.img\Layer_27" * 1
and put it in a model, with the input as the stacked image, and the output as the individual band. From there it would be straightforward to run it as a batch process for all 260 image stacks.
Hope that points you in the right direction!
You can use the Subset tool in batch mode to perform this task. You will have to add a variable for the bands that you want to subset and you will also need to create a text file that lists the full path and filename of the input image along with each band number that you want to use to create each individual image file.
The first thing you need to do is create the text file that contains a list with the full path and filename of the input image along with a single band number on each line. The filename and band number must be separated by a single space. Using a simple text editor such as ERDAS IMAGINE’s built-in text editor found under the Tools menu is ideal (Tools > Edit Text Files). Save this file with a .txt extension. An example of how your text file will look is provided below:
d:/2010_example_data/germtm.img 1 d:/2010_example_data/germtm.img 2 d:/2010_example_data/germtm.img 3 d:/2010_example_data/germtm.img 4 d:/2010_example_data/germtm.img 5 d:/2010_example_data/germtm.img 6
-Open the Subset tool (Data Prep > Subset Image). -Select your input file. -Choose a location and a root name for your output image files. -Enter “1” in the Select Layers field. -Choose the Batch button to launch the Batch Commands wizard. -Select the Modify commands automatically option and click the Next button.
The command should look similar to the following:
modeler -nq subset.pmdl -meter -state "$(Input)" Integer 1 "$(Output)" Unsigned_8_bit Integer '$(Input.Ulx)' '$(Input.Uly)' '$(Input.Lrx)' '$(Input.Lry)' Map useall Continuous "Continuous" "Continuous" "None" '' '' ''
-Click on the Variables tab and click the New button. -Enter “band” for the name of the new variable, leave the Type set to User, and press the key. -Highlight the “Output” variable and change the part of the pattern “$(Input.root)” to “$(band)”. -Click on the Commands tab and highlight the number “1” in the command line which is found after “Integer”. -You will see a drop-down-menu box containing the word "Input" near the bottom of the Batch wizard. Click on that box and change the selection to the "band" variable instead. -Click on the second icon to the right...the icon for "Replace the current argument with the variable". This will change the number “1” in the command line to "$(band)".
The command should now look similar to this:
modeler -nq subset.pmdl -meter -state "$(Input)" Integer $(band) "$(Output)" Unsigned_8_bit Integer '$(Input.Ulx)' '$(Input.Uly)' '$(Input.Lrx)' '$(Input.Lry)' Map useall Continuous "Continuous" "Continuous" "None" '' '' ''
-Click the Next button.
-Highlight the “Input” and “band” columns in the batch tool by holding the key and clicking on the column heading.
-With the columns highlighted, right-click on one of the column headings and select Import.
-Select your text file that you created earlier which contains full path and filename of the input image along with a single band number on each line. -In the Import Column Data dialogue select the Options button, and set the Separator Character to "WhiteSpace" in the Import Column Options dialog. -Click OK to return to the Import Column Data dialog. -Click OK to import your columns into the Batch tool.
-All of your columns should now be populated with the appropriate information.
-Click the Next button and then the "Finish" button to run the command.
For another non-ArcGIS option, I just tried FME and it can do this.
[maybe this won't help you, but for other readers it might be of use]
The transformer to use is the RasterBandSeparator. Then a Tester will filter out the band you want to keep. See screenshot: