I have a feature class of points that represent storm water inlets. I am trying to automate a process that does the following.
- finds all of the inlets that have a field called "Marker" populated with the string "No"
- generate a PDF for each of these features that is a centered view at 1:50 scale.
I'm pretty new to Python. I've been working on this for awhile and keep getting an output of a single PDF (not 800, which is the aprox. # of inlets with "No") and the ArcMap crashes as the script is finishing. I'm sure my code is pretty whack!
enter image description here
-
This is an old question but, as I am confident you now know, questions about code should always have that presented as text rather than a picture.PolyGeo– PolyGeo ♦2017年12月21日 23:03:54 +00:00Commented Dec 21, 2017 at 23:03
1 Answer 1
I would use the "SHAPE@" token with the search cursor, then do something like this:
with arcpy.da.SearchCursor(fc, ("SHAPE@", "UNIQUE_ID")) as searchCur:
for row in searchCur:
myDF.extent = row[0].extent
myDF.scale = 50
arcpy.RefreshActiveView()
arcpy.mapping.ExportToPDF(thisMap,
r"N:27000円s27800円\GIS\John_Working\PDF\Map_" + str(row[1]) + ".pdf",
resolution=100, image_quality="Normal")
-
Thanks! this works perfectly! If you don't mind... Could you elaborate on what I was doing wrong, why is the SHAPE@ token necessary?GeoJohn– GeoJohn2014年10月03日 15:08:18 +00:00Commented Oct 3, 2014 at 15:08
-
1If you are using Search Cursor DA, you do not need to also Select the features. The cursor will go to every row in the "for row in searchCur" loop. The SHAPE@ token returns the geometry of the object, so you can grab that extent and set it as the data frame extent (myDF.extent = row[0].extent), then set the scale, refresh and export the pdf.detroit_hc– detroit_hc2014年10月03日 15:15:03 +00:00Commented Oct 3, 2014 at 15:15
-
That makes a great deal of sense. Thank you for the explanation!GeoJohn– GeoJohn2014年10月03日 15:16:25 +00:00Commented Oct 3, 2014 at 15:16