Can I execute the "Export Raster" tool programmatically so I can get a correctly colored output?

2247
5
07-19-2021 09:31 PM
AnthonyDunk
New Contributor

I can drag a JPG image onto a map in ArcGIS Pro, and then right-click on it in the Contents pane, and chose Data > Export Raster. This brings up a tool that allows me to export the raster with coloration by selecting the "Use Renderer" and "Force RGB" options.

This works fine, but I would like to be able to access this functionality programmatically from C# or Python. Is there a way to do this? The "Export Raster" tool does not seem to be in the Geoprocessing toolbox.

Thanks.

5 Replies
DanPatterson
MVP Esteemed Contributor

The differences are discussed here

Export or convert raster datasets—ArcGIS Pro | Documentation

and copy raster, here

Copy Raster (Data Management)—ArcGIS Pro | Documentation

with other options covered in the Environments settings, such as

Cell Alignment, Cell Size, Compression, Current Workspace, Extent, Geographic Transformations, NoData, Output CONFIG Keyword, Output Coordinate System, Parallel Processing Factor, Pyramid, Raster Statistics, Resampling Method, Scratch Workspace, Snap Raster, Tile Size

have you tried copy raster with settings for the particular environments using arcpy (eg those that are associated with cell size, renderer etc)


... sort of retired...
0 Kudos
AnthonyDunk
New Contributor

Thanks. The Copy Raster geoprocessing tool is a good start, but it only creates colored output if the raster was an image (e.g. jpg). If the raster is a grid then the rendered color map is not being exported to the image - it just comes out as all white, or in black and white. I need access the "Use Renderer" option which only seems to be available in the Export Raster tool...

DanPatterson
MVP Esteemed Contributor

try *.tif as outputs... it is esri's preferred raster format for most geoprocessing operations.

And I do remember something fuzzy about histograms and statistics, defining nodata value explicitly in environments and not using stretch for symbology if you want to retain color... but that was earlier today

So try another raster format with your environment parameters set to what you want


... sort of retired...
0 Kudos
TomasPokorny
New Contributor III

same here... definitely need Use Renderer for export rasters via arcpy...

0 Kudos
AnthonyDunkDatamineDev1
New Contributor II

I found a way to do this through the SDK, although it's a bit of a cludge... You need to zoom to the raster layer you want to export, turn off all other layers and then call MapView.Active.Export() with an ExportFormat object as the input argument. For example a TIFFFormat object.

0 Kudos