2

I'm trying to edit a stretched raster legend item to only show values instead of the "High : " and "Low : " that are standard. I've created a layer template that doesn't include the high/low in the labels, and if I add that layer to a dataframe in ArcMap it works fine:

enter image description here

But when I execute the following code and export the PDF, the high/low shows up in the labels:

enter image description here

dfRef = arcpy.mapping.ListDataFrames(mxd, "dfTile" + str(iRef))[0]
dfRef.spatialReference = srUTM
lgdRef = arcpy.mapping.ListLayoutElements(mxd, "LEGEND_ELEMENT", "dfTile" + str(iRef) + "_legend")[0]
result4 = arcpy.MakeRasterLayer_management(pathScratchGDB + "tempElev_Final", "tempRaster4")
layer4 = result4.getOutput(0)
arcpy.ApplySymbologyFromLayer_management(layer4, pathTemplateLayers + "/elevation_template.lyr")
arcpy.mapping.AddLayer(dfRef, layer4, "TOP")
arcpy.RefreshActiveView()
arcpy.RefreshTOC()
arcpy.mapping.ExportToPDF(mxd, r'C:\Imagery\temp.pdf')

I've tried creating a custom legend item style and updating it using the updateItem method found here but that didn't work either.

Does anyone know how to control stretched raster legend labels via ArcPy?

  • I once used some convoluted work-around where I converted the legend to graphics, kept only the bar, and then coded the insertion of the relevant values at either end of the bar (by setting empty text elements in place and populating them based on the min-max of the raster). – Tom Apr 6 '16 at 15:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.