ArcGIS Python Map Book PDF not working blank PDF -


the purpose of code make pdf map book displays of large lakes in north america. i'm trying run code make map book gives me blank pdf. how can fix this?

## import arcpy module import arcpy import math import os arcpy import env arcpy.env.overwriteoutput = true  # define inputs , outputs - script arguments  arcpy.env.workspace = r"f:\geog173\lab7\lab7_data"  lakes = "na_big_lakes.shp" cities = "na_cities.shp" na = "north_america.shp"   ##python arguments ## arguments = na_big_lakes.shp na_cities.shp new_lakes.shp  center_lakes.shp  lakes= 'na_big_lakes.shp' na = 'north_america.shp' cities = 'na_cities.shp' ##new_lakes = 'new_lakes.shp' ##center_lakes = 'center_lakes.shp'  # identify geometry field desc = arcpy.describe(lakes) shapename = desc.shapefieldname  # identify geometry field in cities shapefile ##desc = arcpy.describe(cities) ##shapefieldnamecity = desc.shapefieldname  #get lake cursor inrows = arcpy.searchcursor(lakes)  # set variables output path , pdf file name outdir = r"f:\geog173\lab7\lab7_data" finalmappdf_filename = outdir + r"\na_big_lake_mapbook.pdf"   # check whether mapbook pdf exists. if does, delete it. if os.path.exists(finalmappdf_filename):     os.remove(finalmappdf_filename)  # create map book pdf finalmappdf = arcpy.mapping.pdfdocumentcreate(finalmappdf_filename)  # create mapdocument object pointing specified mxd mxd = arcpy.mapping.mapdocument(outdir + r"\originalmap.mxd")  # dataframe df = arcpy.mapping.listdataframes(mxd)[0]  # ----------------------------------------------------------------------------# # start appending pages. title page first. # ----------------------------------------------------------------------------# # find text element value "test", , replace other value maptext = "a map book north american large lakes " + '\n\r' + "kishore, a., geog173, geography, ucla" +  '\n\r' + " lake number: 18" +  '\n\r' + " total area: 362117 km2" +  '\n\r' + " mean area: 20118 km2" print maptext elm in arcpy.mapping.listlayoutelements(mxd, "text_element"):     if elm.text == "test":         elm.text = maptext  arcpy.refreshtoc() arcpy.refreshactiveview()  #df.extent = feature.extent arcpy.mapping.exporttopdf(mxd, outdir + r"\tempmappages.pdf")  # append multi-page pdf finalmappdf finalmappdf.appendpages(outdir + r"\tempmappages.pdf")  #initialize text value, can reused in next iteration elm in arcpy.mapping.listlayoutelements(mxd, "text_element"):     if elm.text == maptext:         elm.text = "test"   # ----------------------------------------------------------------------------# # loop through each lake # ----------------------------------------------------------------------------#  # loop through each row/feature lakecount = 0 row in inrows:     lakecount = lakecount + 1     city_name = ""     cntry_name = ""     admin_name = ""     pop_class = ""     distance = 0     xy = ""     #print "shapename" , shapename     # create geometry object     feature = row.getvalue(shapename)     maptext = "lake fid: " + str(row.fid) +  ", area (km2): " + str(row.area_km2)     print maptext      # find text element value "test", , replace other value     elm in arcpy.mapping.listlayoutelements(mxd, "text_element"):         if elm.text == "test":             elm.text = maptext       arcpy.refreshtoc()     arcpy.refreshactiveview()      df.extent = feature.extent     arcpy.mapping.exporttopdf(mxd, outdir + r"\tempmappages.pdf")      # append multi-page pdf finalmappdf     finalmappdf.appendpages(outdir + r"\tempmappages.pdf")   # set properties adobe reader , save pdf. finalmappdf.updatedocproperties(pdf_open_view = "use_thumbs",                              pdf_layout = "single_page")         finalmappdf.saveandclose()   # done. clean , let user know process has finished. del row, inrows del mxd, finalmappdf print "map book lakes in north america complete!" 

first off should remove last lines of code delete mxd. run code again , inspect mxd. data layers drawing properly? recommend having code works before performing file cleanup can identify potential errors.


Comments

Popular posts from this blog

c# - DetailsView in ASP.Net - How to add another column on the side/add a control in each row? -

javascript - firefox memory leak -

Trying to import CSV file to a SQL Server database using asp.net and c# - can't find what I'm missing -