nepomuck0

Autom. production of several maps with same extent but different content (layers)

Discussion created by nepomuck0 on Mar 8, 2013
Latest reply on Mar 22, 2013 by jbarrette-esristaff
Hi there,

I'm trying to automate the map production of several rockfall-model outputs: I have got different rasterlayers (e.g. rockenergy, reach probability, passing height, ...)  from different model scenarios (e.g. without forest, with forest, with forest gaps, ...). All with the same name in different grouplayers. All thogether there are more than 200 .asc rasters, that i want to get out of the GIS on to the paper. Unfortuately i haven't found an "out of the box" tool, so i began with my poor knowledge of python and the arcpy.mapper. Beneth is my result so far

# ---------------------------------------------------------------------------
# map_production.py
# 
# Description: "Should" generate jpg layout outputs of the input layernames
# ---------------------------------------------------------------------------

print "START map production"

print "arcpy importieren"
import arcpy
print "done arcpy import"


print "mxd spezifizieren"
#Specifies mxd  
mxd = arcpy.mapping.MapDocument(r"H:/Desktop/Masterarbeit/test/Besprechung_Schmitten_Neu_6.mxd")
print "done mxd spezifizieren"

print "dataframe spezifizieren"
#Specifies dataframe of interest
df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0]
print "done df spezifizieren"

#Turns all layers off
"alle Layer unsichtbar machen"
for lyr in arcpy.mapping.ListLayers(mxd,"",df):
   lyr.visible = False
   arcpy.RefreshTOC()
   arcpy.RefreshActiveView()
   
"alle Layer unsichtbar gemacht"

#Turns backgroundlayers on
"Hintergrundlayer sichtbar machen"
for lyr in arcpy.mapping.ListLayers(mxd, "hillshade*", df):
   lyr.visible = True
   arcpy.RefreshTOC()
   arcpy.RefreshActiveView()


print "start E_95CI"
#Loops through the layers given in the quotas (eg. beginning with E_95CI) and creates a list of Layers:
for lyr in arcpy.mapping.ListLayers(mxd, "E_95CI", df):
    #For Each: Turn it on:
   lyr.visible= True
   arcpy.RefreshTOC()
   arcpy.RefreshActiveView()
   arcpy.mapping.ExportToJPEG(mxd, r"H://Desktop/e95_cl_jpg.test.jpg")
   
print "done_ 1"


#print "start reach_probability"
##Loops through the layers given in the quotas (eg. reach_probability) and creates a list of Layers:
#for lyr in arcpy.mapping.ListLayers(mxd, "reach_probability", df):
    #For Each: Turn it on:
#   lyr.visible= True
#   arcpy.RefreshTOC()
#   arcpy.RefreshActiveView()
#   arcpy.mapping.ExportToJPEG(mxd, r"H://Desktop/e95_cl_jpg.test.jpg")



#print"done_2"


#Saves mxd
mxd.save()

print "done_ 20"




#Deletes the reference to the mxd from memory (not the actual mxd file)
del mxd



One main problem is, that after one exportet .jpg-map, the second would overwrite the first, which produces an error. How can i get an variable .jpg-output name? It would be perfect, when the name would differ by the name of the group-layer.

The next one is, that there is nothing visible in the jpg. output beside the northarrow and scalebar. Not even the Background :S

Does someone see my faults?

Or does someone know an already existing tool for my problem :cool: ?

Thanks a lot!

Outcomes