I set symbology and exported each raster in my mxd (one by one) to jpg file. My script is ok and it works (it is shown at the bottom).

The question is: how can I customly set my legend?

Now I have those standard labels ("High: #max.number" and "Low: #min.number"), see the image link.

Is it possible to use a python script that sets labels different, for example "Max. value: #maximum number" and "Min. value: #minimum number"?

I have 200 images and renaming each legend is time consuming...

image link (example):

enter image description here

for lyr in arcpy.mapping.ListLayers(mxd):
    arcpy.ApplySymbologyFromLayer_management(lyr, "my_first_layer")
for lyr in arcpy.mapping.ListLayers(mxd):
    #turn off all layers
    lyr.visible = False
for lyr in arcpy.mapping.ListLayers(mxd):
    #turn one layer on at a time and export ...
    lyr.visible = True<BR>
    arcpy.mapping.ExportToJPEG(mxd, "D:\\Users\\JPG_FILES\\"+ lyr.name 
    lyr.visible = False

If you are using ArcGIS 10.1 then the new RasterClassifiedSymbology class of arcpy.mapping may be what you need to look at.

  • 2
    Yeah, 10.0 does not have this option. – Tomek Oct 23 '12 at 10:02
  • thank you for the advice. but it doesn't help. i don't have classidfied symbology. i have stretched symbology. when i check lyr.symbologyType it returns me "OTHER". – Rok Oct 23 '12 at 12:23
import arcpy, sys, os, string 

arcpy.env.workspace = "PATH USER"

mxd_list = arcpy.ListFiles("*.mxd")

for mxd in mxd_list:

    current_mxd = arcpy.mapping.MapDocument(os.path.join(ws, mxd))
    jpg_name = mxd[:-4] + ".jpg"
    arcpy.mapping.ExportToJPEG(current_mxd, jpg_name, resolution = NUMBERUSER)

del mxd_list
  • can you provide an explanation to your answer? – MrXsquared Jul 27 '19 at 3:24

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.