Select to view content in your preferred language

Model Builder Iterate layer files to PNG

3023
1
06-24-2016 02:02 AM
Henk_PieterSterk
New Contributor

For a comparison analysis of intersected polygon feature classes I am trying to export 253 layer files to a PNG image using the Model Builder.

Unfortunately the 'Iterate Files' tool in the Model Builder won't let me iterate through the the .lyr-files in the workspace.

I am trying to use the following arcpy tool in a script linked to the iterator:

arcpy.mapping.ExportToPNG

It gives me the following error, as a .lyr file is nothing more than a reference to symbology and a feature class.

Failed to execute. Parameters are not valid.

ERROR 000840: The value is not a File.

Failed to execute (LayertoPNG).

Hopefully someone could help me out, as I couldn't make this script work either:

arcgis 10.0 - Export each layer in map to a separate image - Geographic Information Systems Stack Ex...

or:

python - Arcmap: save all layers in Table of Contents to layer files - Geographic Information System...

0 Kudos
1 Reply
FC_Basson
MVP Regular Contributor

Try creating an in-memory Layer file while iterating and working with that instead:

# list lyr files in workspace
lyrs = arcpy.ListFiles("*.lyr")
for l in lyrs:
  lyr = arcpy.mapping.Layer(arcpy.Describe(l).catalogPath)
  layers = arcpy.mapping.ListLayers(lyr)
  for layer in layers:
    # process layer
0 Kudos