import arcpy try: #Specifies mxd mxd = arcpy.mapping.MapDocument(r"H:/Desktop/Masterarbeit/test/Besprechung_Crap Ses.mxd") #Specifies dataframe of interest df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] #Specifies layer file with the symbology you want to apply to the other raster layers sourceLayer = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files\Reach Probability.lyr") #Loops through layers in the first data frame in your mxd and #creates a list of Layers starting with Reach_probability: for lyr in arcpy.mapping.ListLayers(mxd, "Reach_probability*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer) #Saves mxd mxd.save() finally: #Deletes the reference to the mxd from memory (not the actual mxd file) del mxd
# --------------------------------------------------------------------------- # iteration durch raster_und symbol.py # Created on: 2012-12-31 01:39:43.00000 # (generated by ArcGIS/ModelBuilder) # Description: # --------------------------------------------------------------------------- import arcpy #Specifies mxd mxd = arcpy.mapping.MapDocument(r"H:/Desktop/Masterarbeit/test/Besprechung_Crap Ses.mxd") #Specifies dataframe of interest df = arcpy.mapping.ListDataFrames(mxd, "Layers")[0] #Specifies layer file with the symbology you want to apply to the other raster layers sourceLayer1 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\E_95CI.lyr") sourceLayer2 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\E_95CI_diff.lyr") sourceLayer3 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\E_mean.lyr") sourceLayer4 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\E_mean_diff.lyr") sourceLayer5 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Nr_depos_diff.lyr") sourceLayer6 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Nr_deposited.lyr") sourceLayer7 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Nr_pass_diff.lyr") sourceLayer8 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Nr_passages.lyr") sourceLayer9 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Nr_tree_impacts.lyr") sourceLayer10 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Ph_95CI.lyr") sourceLayer11 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Ph_95CI_diff.lyr") sourceLayer12 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Ph_mean.lyr") sourceLayer13 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Ph_mean_diff.lyr") sourceLayer14 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Reach Probability [%].lyr") sourceLayer15 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Reach_prob_diff.lyr") sourceLayer16 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Rvol.lyr") sourceLayer17 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Rvol_diff.lyr") sourceLayer18 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Tree_impact_heights .lyr") sourceLayer19 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Vmax.lyr") sourceLayer20 = arcpy.mapping.Layer(r"H:\Desktop\Masterarbeit\test\RESULTATE\lyr_files_neu\Vmax_diff.lyr") #Loops through layers in the first data frame in your mxd and #creates a list of Layers starting with Reach_probability: for lyr in arcpy.mapping.ListLayers(mxd, "E_95CI", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer1) print "done_ 1" for lyr in arcpy.mapping.ListLayers(mxd, "E_95CI_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer2) #Saves mxd mxd.save() print "done_2" for lyr in arcpy.mapping.ListLayers(mxd, "E_mean", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer3) print "done_3" for lyr in arcpy.mapping.ListLayers(mxd, "E_mean_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer4) #Saves mxd mxd.save() print "done_4" for lyr in arcpy.mapping.ListLayers(mxd, "Nr_depos_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer5) print "done_5" for lyr in arcpy.mapping.ListLayers(mxd, "Nr_deposited", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer6) #Saves mxd mxd.save() print "done_6" for lyr in arcpy.mapping.ListLayers(mxd, "Nr_pass_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer7) print "done_7" for lyr in arcpy.mapping.ListLayers(mxd, "Nr_passages", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer8) #Saves mxd mxd.save() print "done_8" for lyr in arcpy.mapping.ListLayers(mxd, "Nr_tree_impacts*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer9) print "done_9" for lyr in arcpy.mapping.ListLayers(mxd, "Ph_95CI", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer10) #Saves mxd mxd.save() print "done_10" for lyr in arcpy.mapping.ListLayers(mxd, "Ph_95CI_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer11) print "done_11" for lyr in arcpy.mapping.ListLayers(mxd, "Ph_mean", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer12) #Saves mxd mxd.save() print "done_12" for lyr in arcpy.mapping.ListLayers(mxd, "Ph_mean_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer13) print "done_13" for lyr in arcpy.mapping.ListLayers(mxd, "Reach Probability [%]*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer14) #Saves mxd mxd.save() print "done_14" for lyr in arcpy.mapping.ListLayers(mxd, "Reach_prob_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer15) print "done_15" for lyr in arcpy.mapping.ListLayers(mxd, "Rvol", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer16) #Saves mxd mxd.save() print "done_15" for lyr in arcpy.mapping.ListLayers(mxd, "Rvol_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer17) print "done_17" for lyr in arcpy.mapping.ListLayers(mxd, "Tree_impact_heights *", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer18) #Saves mxd mxd.save() print "done_18" for lyr in arcpy.mapping.ListLayers(mxd, "Vmax", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer19) print "done_19" for lyr in arcpy.mapping.ListLayers(mxd, "Vmax_diff*", df): #Determines if layer is a raster layer and applies lyr symbology if it is if lyr.isRasterLayer: arcpy.ApplySymbologyFromLayer_management(lyr, sourceLayer20) #Saves mxd mxd.save() print "done_ 20! ! " #Deletes the reference to the mxd from memory (not the actual mxd file) del mxd
Aangemelde leden kunnen berichten plaatsen, updates volgen en meer. Nieuw hier? Registreer een gratis account.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.