samedi 31 janvier 2015

python code doesn't preserve original range of values from my raster colormap template


I'm working towards an animation or movie of some distributed model output so I need to use a batch process for several hundred rasters that applies a consistent colormap and value range, however the code imports the colormap template but NOT the original range of the template. I can preserve the range if I go file by file and click properties, symbology, click on the import button with the picture of the open folder next to the save button, and import the template layer. What can I do to the code to preserve range and make it a batch process?? Also, it looks like I'll need to batch save my jpgs as .lyr files, but one step at a time. Thanks!



# Import system modules
import arcpy
from arcpy import env

# Set the current workspace
env.workspace = r"C:\VMshared\small_example_valley2"

# Set layer to apply symbology to
inputLayer = "snowdepthN0001.tif.jpg.lyr"

# Set layer that output symbology will be based on
symbologyLayer = r"C:\VMshared\small_example_valley2\snowdepthcolor3\snowdepthCOLOR.tif.lyr"

# Apply the symbology from the symbology layer to the input layer
arcpy.ApplySymbologyFromLayer_management (inputLayer, symbologyLayer)


**edit --- The code below gives me a whole bunch of errors. Any ideas? Do I need mean and std dev if I just want to set max and min?



# Import system modules

import arcpy

from arcpy import env
arcpy.env.overwriteOutput = True

# Set the current workspace
env.workspace = r"C:\Users\afullhar\Documents\ArcGIS"

# Set layer that output symbology will be based on
symbologyLayer = r"C:\VMshared\small_example_valley2\snowdepthcolor3\snowdepthCOLOR.tif.lyr"

for lyr in arcpy.mapping.ListLayers(r"C:\Users\afullhar\Documents\ArcGIS"):

arcpy.ApplySymbologyFromLayer_management(lyr,symbologyLayer)
arcpy.SetRasterProperties_management(lyr,"ELEVATION","1 3437 5033 4236 462","#","#")




Aucun commentaire:

Enregistrer un commentaire