0

I know that to export a raster with a given color, you need to export it. You need to specify the parameters in the "Data Export" section in the Output raster section: Color. model and RGB. But how can this export be done for multiple rasters at the same time? I have compiled a script for batch execution, but it does not perform what I expected.

import arcpy
import os

output_folder = 'F:/mol_2_N02/1/img'
mxd = arcpy.mapping.MapDocument("CURRENT")
df = arcpy.mapping.ListDataFrames(mxd)[0]

for lyr in arcpy.mapping.ListLayers(mxd, "", df):
    if lyr.isRasterLayer:
        raster_path = lyr.dataSource
        
        if raster_path.lower().endswith('.tif'):
            raster_name = os.path.basename(raster_path)
            new_raster_name = raster_name.replace('.tif', '_copia.tif')
            new_raster_path = os.path.join(output_folder, new_raster_name)
        
            arcpy.CopyRaster_management(lyr, new_raster_path, '', '', '', 'NONE', 'NONE', '')

print("Finish.")

1 photo - what do I set in the Data Export so that the output raster is with the specified color Text

2 photo - which rasters do I need to export Text

3 photo - what I get after running the script Text

I'm trying to batch export rasters with their color scheme, which they currently have. Such rasters were obtained when executed with the "Kriging" tool.

2
  • I'm not understanding what you're trying to do, is the raster to have a single constant value or is it that you wish to apply the symbology (stretch) to a group of rasters? The images you've put in your question aren't working. Commented May 15 at 6:52
  • 1
    I see, you're trying to export using a renderer. There's no chance of doing this in python gis.stackexchange.com/questions/140196/… , you'd need to use C#, C++ or VB.net to leverage the ArcObjects API. gis.stackexchange.com/questions/177580/… has a bit of code. Perhaps the closest you could get is to use export map to a GeoTIFF file. Consider making a mosaic dataset from all your rasters, symbolize it once, export it once and then cut it up if you need smaller tiles. Commented May 15 at 8:00

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.