I've created a model that when finished creates two symbolized raster layers and adds them to the dataframe.

I would now like each layer to be exported as a unique png file.

Is there a tool that I can add to my model to complete this task?

See the model below. I would actually like to create two pngs, one of phaseFinished.lyr and another of activityFinished.lyr.

enter image description here


2 Answers 2


The Help on ExportToPNG (arcpy.mapping) says that it:

Exports the page layout or data frame of a map document (.mxd) to the Portable Network Graphics (PNG) format.

To include this in ModelBuilder you will need to write a short Python Script tool.

import arcpy

lyrFile = arcpy.GetParameterAsText(0)
pngFile = arcpy.GetParameterAsText(1)

mxd = arcpy.mapping.MapDocument("<PATH>/empty.mxd")
df = arcpy.mapping.ListDataFrames(mxd,"Layers")[0]
addLayer = arcpy.mapping.Layer(lyrFile)
arcpy.mapping.AddLayer(df, addLayer)
arcpy.mapping.ExportToPNG(mxd, pngFile, df)
del mxd

The sketched out steps for that are:

  1. Open ArcMap with a Blank Map and save it as something like empty.mxd in a location where you can rely on always finding it.
  2. Write Python script (see above) - I use IDLE to do this
  3. Open Catalog window (I use ArcMap) to create a new toolbox
  4. Right click on the new toolbox to Add Script tool.
  5. Browse to the *.py script created in step 2 to link that to your tool
  6. When you get to the final panel of that wizard create two parameters (Input Layer File of type File to be read as lyrFile and Output PNG File of type string to be read as pngFile)
  7. Test your tool standalone, and when it works drag and drop it into your model.

If this does not "just work" I recommend that you edit your question to show which of these steps you have performed successfully and which may need further explanation.


You can add the Copy Raster tool to export your final rasters to PNG. https://pro.arcgis.com/en/pro-app/latest/tool-reference/data-management/copy-raster.htm

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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