Errata for Programming ArcGIS 10.
1 with Python Cookbook
Chapter 3
Page 55
Step 6:
Should be a wildcard (*) after Burg as follows:
layers = mapping.ListLayers(mxd, Burg*, df)
Page 55
Step 8:
Remove the double quote around Burg* so that it appears as follows:
layers = mapping.ListLayers(mxd, Burg*, df)
The print statement should be indented inside the for loop as seen below:
for layer in layers:
print layer.name
Page 57
Step 8:
Make sure the line that creates the layers variable and the next line that creates the for loop are
indented the same. It should appear as seen below.
layers = mapping.ListLayers(mxd, Crime Density by School District, df)
for layer in layers:
Chapter 4
Page 80
Step 5:
Should be Reference the Crime_DataLinksFixed.mxd mapdocument file:
mxd = mapping.MapDocument(rc:\ArcpyBook\Ch4\Crime_DataLinksFixed.mxd)
Page 83
Step 4:
Should be Reference the Crime_DataLinksLayer.mxd map document file:
mxd = mapping.MapDocument(rc:\ArcpyBook\Ch4\Crime_DataLinksLayer.mxd)
Chapter 5
Page 97
Step 5:
Add a colon to the end of the for loop
for el in mapping.ListLayoutElements(mxd, LEGEND_ELEMENT, *Crime*):
Page 104
Step 8:
Should be:
mapping.ExportToPDF(mxd, rc:\ArcpyBook\Ch5\Map_DataFrameCrime.pdf, df)
Page 106
Step 7:
Should be:
mapping.ExportToJPEG(mxd, rc:\ArcpyBook\Ch5\DataFrameCrime2.jpg, df, world_file=True)
Page 107
Step 5:
Should be:
pdfDoc.appendPages(rc:\ArcpyBook\Ch5\DataFrameCrime.pdf)
Chapter 6
Page 123
Step 4:
Needs to include quotes around Streams_Buff and leave off the last double quote around Feet. So it
should be:
arcpy.Buffer_analysis(Streams.shp, Streams_Buff, 200 Feet)
Chapter 7
Page 129
Step 8:
Should be:
arcpy.CreateFeatureclass_management(os.path.split(outputFC)[0], os.path.split(outputFC)[1], point,
fClassTemplate)
Chapter 9
Pages 177, 178
Step 13 and 18
Should be:
with arcpy.da.InsertCursor
Instead of
with da.InsertCursor
Page 188-189
Step 8
Should be:
edit = arcpy.da.Editor(rc:\ArcpyBook\data\CityOfSanAntonio.gdb)
Page 191
Step 4:
Should be:
infc = c:/ArcpyBook/data/CityOfSanAntonio.gdb/SchoolDistricts
Chapter 10
Page 199
Step 7:
Should be:
except Exception as e:
Page 205
Step 9:
Should be:
exception Exception as e:
Page 207
Step 5:
Should be:
descWorkspace = arcpy.Describe(c:/ArcpyBook/data/CityOfSanAntonio.gdb)
Page 207
Step 8:
Should be:
exception Exception as e:
Chapter 11
Page 222
Step 17:
Should be:
def onClick(self)
arcpy.ImportToolbox(c:/ArcpyBook/Ch7/WildfireTools.tbx)
arcpy.LoadWildfires_wildfire()
Note: This can only be called if you completed Chapter 7 which had you create a script tool called
LoadWildfires. If you named the script tool something else youll need to update this code to whatever
you called the script tool. If you didnt complete the Chapter 7 exercise then you wont be able to test
this particular add-in. Thats ok though just find another script tool in ArcToolbox that you can execute
and use that instead. Just continue through the step so that you understand how to create the add-in.
Page 231
Step 12:
Should be: (note the changes to the indentation)
if arcpy.Exists(randompts.shp)
Arcpy.Delete_management(randompts.shp)
randompts = arcpy.CreateRandomPoints_management(arcpy.env.workspace, randompts.shp, ,
rectangle_geometry)
arcpy.RefreshActiveView
return randompts
Chapter 12
Page 242
Step 5:
Indentation is incorrect. Should be:
Except:
Print Error foundin Buffer tool \n
errCode = arcpy.GetReturnCode(3)
if str(errCode) in 735:
print Distance value not provided \n
print Running the buffer again with a default value \n
defaultDistance = 100 Feet
arcpy.Buffer_analysis(Streams.shp, Streams_Buff, defaultDistance)
print Buffer complete
Appendix B
Page 271
Step 4:
The file location has changed on this.