Convert 16bit to 8bit Tifs (Hope to Batch)

5726
15
08-25-2010 06:33 AM
City_ofNorth_Bay
New Contributor III
The Export Raster Data Tool (accessed through right click - Data - Export Data in ArcView) allows the user to select the "Use Renderer" option. This option seems to convert my 16bit tifs into 8bit tifs properly. Problem is I cannot use this tool in a Model to repeat it multiple times.

Any Ideas?
Thanks in advance.
0 Kudos
15 Replies
StephanieLeusink
New Contributor III
I have also run into this and am looking for a way to use the Export Raster Data Tool (accessed through right clicking on the raster in ArcMap and selecting Data - Export Data) either in ModelBuilder or through a python script.  I have 50+ 16bit tifs that I need to convert to 8bit, and this tool has produced the best results so far.
0 Kudos
CarrieDavis
Occasional Contributor
Hi

The "use render" option will save the current raster renderer settings to an exported raster dataset. So, it is useful if you would like to set a particular stretch and have the exported raster display as this stretch by default.  This option is not available in a geoprocessing tool, but the option to change the raster�??s pixel depth is available through the Data Management > Copy Raster tool. 

Copy Raster ArcGIS Resource center help doc:
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//001700000094000000

Copy Raster can be batched by right clicking on the tool and selecting �??Batch�?� or  in model builder by inserting the Iterate Rasters tool. With version 10, the Copy Raster tool may also be batched in python using arcpy.ListRasters.  For example:
[ATTACH=CONFIG]14530[/ATTACH]

Or if in 9.3 use arcgisscripting.  The script sample is available in the Copy Raster help document for 9.3 at http://webhelp.esri.com/arcgisdesktop/9.3/body.cfm?id=1913&pid=1912&topicname=Copy%20Raster%20(Data%....

Hope this helps!  Carrie D.
0 Kudos
StephanieLeusink
New Contributor III
Thanks for the response Carrie.

I'm currently using the Export Raster Data because the "User Renderer" and "Force RGB" check boxes are producing the results I need.  It sounds like I can't access these options any other way, besides right-clicking on each image individually.

It would be wonderful if these options could be built into a tool that can be accessed in a model or through python.  From my searching for solutions online, it sounds like there are a few others who would find this useful too!
0 Kudos
CarrieDavis
Occasional Contributor
Hi SLeusink ,

Do your Tiffs have colormaps?  If so the Copy Raster tool does have a parameter that will convert colormaps to RGB.
0 Kudos
StephanieLeusink
New Contributor III
No, there are no colormaps present.  They are 16bit tiffs with 4 bands present, and within ArcMap, on the Symbology tab of the raster properties, I'm setting the Red, Green, and Blue channels to the band combination that I want to display and then using the Export Raster Data tool to convert it to 3 band, 8bit tiffs.  It would be great if I could write a script that would loop through all the rasters in the TOC and export them using the same settings, instead of doing each separately.
0 Kudos
CarrieDavis
Occasional Contributor
I'm sure there is a way to do this using ArcObjects.  That's a different forum.   There is a quick way to do a similar procedure batch style with model builder.  Below is a print screen of a set of tools linked in model builder that will iterate, create a raster layer with your specified band combo and then copy the layer as a 3 band raster.

[ATTACH=CONFIG]14537[/ATTACH]

I just tested this real quick on some local data I have that is an 8 band raster and was able to specify an output raster as 3 band with combo of 1,3,4. This raster was saved as an 8 bit unsigned integer.  This required the use of three tools; Iterate Raster, Make Raster layer, and Copy Raster.  Iterate Raster is inserted into the model to loop through a workspace and perform a function on each raster within the workspace.  Then I set the band combination in the Make Raster layer tool (Type in the band numbers in the "Bands" parameter and select the + button to add). 

[ATTACH=CONFIG]14538[/ATTACH]

Use the Raster Layer as input into the Copy Raster tool.  The output may be specified to a particular folder as \\servername\outputRas\%Name%

I realize it might take some inital time to familarize yourself with these tools, but they may be helpful down the road.

Iterate Rasters (Model Builder)
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00400000000z000000.htm

Make Raster Layer
http://help.arcgis.com/en/arcgisdesktop/10.0/help/index.html#//00170000006t000000
0 Kudos
StephanieLeusink
New Contributor III
Hi Carrie,

I've tried your model, and it looks like the Make Raster Layer will work to choose the bands I want, but the Copy Raster tool is not able to properly rescale the pixel values from 16bit to 8bit.  It even says so in the Tool Help:

"The pixel type parameter determines the bit depth of the output raster dataset. There is rescaling of the raster values when a different pixel type is chosen. If the pixel type is demoted (lowered), the raster values outside the valid range for that pixel depth will be truncated and lost."

So, when I go from a false-color 16bit tiff to an 8bit tiff with Copy Raster, my image is completely lost (see first 2 attachments).

For some reason, the Export Raster Data tool within ArcMap is able to properly rescale the values for all three bands so that the resulting 8bit image looks almost identical to the original 16bit image, which is what I'm looking for (see second 2 attachments).
0 Kudos
EricRice
Esri Regular Contributor
The Export Raster Data Tool (accessed through right click - Data - Export Data in ArcView) allows the user to select the "Use Renderer" option. This option seems to convert my 16bit tifs into 8bit tifs properly.


I'm just going to throw this out there for everyone.  There is no conversion from 16 bit data to 8 bit data using the Export Dialog.  However, using the options "Use Renderer" and "Force RGB", there is a conversion from 16 bit data to an 8 bit picture of your data which is why it looks nearly identical.  Its similar to taking a screenshot.  Was this your goal?

Why do you want to go from 16 bit to 8 bit?

Best Regards,
Eric
0 Kudos
StephanieLeusink
New Contributor III
I need my imagery to be 8bit because of compatibility issues with other data.

If this Export Dialog just produces a screenshot, which you seem to imply is not the correct way to do things, then what process would you suggest using to convert 16bit to 8bit while retaining the look/detail of the original imagery?

And how is the 8bit output that I'm getting from the Export Dialog tool inaccurate?  I'm not really familiar with the technical side of imagery formats and bit depth, but it seems to be producing the results I need.
0 Kudos