AnsweredAssumed Answered

Automatic Map creation with Python

Question asked by kachieng on Nov 25, 2014
Latest reply on Nov 26, 2014 by xander_bakker

Hi,

I used this Python code to generate a series of codes from a single layer in an existing map document. However, the code returned an error message when I run it. Could you please help me figure out what could have gone wrong?

 

 

import arcpy

 

 

arcpy.env.overwriteOutput=True

 

mxd = arcpy.mapping.MapDocument(r"\\bsedom5\users\kachieng2\Desktop\Achieng\Python\Lesson1\Lesson1\ModelPractice.mxd")

DataFrame = arcpy.mapping.ListDataFrames(mxd)[0]

polygonLayer = arcpy.mapping.ListLayers(mxd, "us_cities.shp", DataFrame)[0]

Columns = arcpy.ListFields (polygonLayer)

for col in Columns:

    arcpy.CalculateField_management(polygonLayer , "DummyColumn", col, "PYTHON_9.3")

    arcpy.mapping.ExportToPNG(mxd, r"\\bsedom5\users\kachieng2\Desktop\Achieng\Python\Lesson1\Lesson1\maps"+ c + ".png")

 

 

Thanks in advance

 

Kevin

Attachments

Outcomes