Select to view content in your preferred language

Export Raster Data

2938
3
08-16-2011 08:12 AM
WadeGivens
Emerging Contributor
Is there a way to duplicate the functionality found when you right-click on a rster layer and choose "Export"?  I'm trying to convert 32 bit images to 8 bit similar to the way you can check the Use Renderer and Froce RGB option in the Export Raster Data window.  I've tried using CopyRaster_management, but the results I get from that tool are incorrect (I get a raster image where all the pixels have the same value:

arcpy.CopyRaster_management("test", "C:/Temp/grids/test_8bit.tif", "", "", "", "", "ColormapToRGB", "8_BIT_UNSIGNED")

I've tried every possible combination of parameters to no avail...

Wade
Tags (2)
0 Kudos
3 Replies
HemingZhu
Frequent Contributor
Is there a way to duplicate the functionality found when you right-click on a rster layer and choose "Export"?  I'm trying to convert 32 bit images to 8 bit similar to the way you can check the Use Renderer and Froce RGB option in the Export Raster Data window.  I've tried using CopyRaster_management, but the results I get from that tool are incorrect (I get a raster image where all the pixels have the same value:

arcpy.CopyRaster_management("test", "C:/Temp/grids/test_8bit.tif", "", "", "", "", "ColormapToRGB", "8_BIT_UNSIGNED")

I've tried every possible combination of parameters to no avail...

Wade


I think the problem might lie in your pixel_type parameter. The tool help stated: If the pixel type is demoted (lowered), the raster values outside the valid range for that pixel depth will be truncated and lost. 8_BIT_UNSIGNED value range from 0-255 while 32_BIT_UNSIGNED value range from 0 to 4,294,967,295. Try the same pixel_type as your orignal raster and see what happens.
0 Kudos
WadeGivens
Emerging Contributor
I saw that as well.  Guess that defeats the purpose of using the python call for what I'm trying to accomplish.  I'm surprised the the function doesn't work the same as the export method from the TOC.

Wade
0 Kudos
RoyHewitt
Deactivated User
I'm trying to do something similiar to this ESRI Blog Post to detail focus areas.  I need to Force RGB in order to add Image Analysis functions to achieve the effect.  Since I'm doing this on several focus areas I'd like to automate it.

Is there any functionality in arcpy that allows you to FORCE RGB??
0 Kudos