I am using a large dataset out of SDE which has many shapefiles within it. It contains parcels of land for which I need to make a map for each parcel. I think datadriven pages would be adequate and am going to give that a try. Thank you.
import arcpy, os #set map doc and the layer to be used mxd = arcpy.mapping.MapDocument("Current") mapLyr = arcpy.mapping.ListLayers(mxd, "IA_Detail_2010")[0] #Get page number from data driven page - specified in the tool parameter dialogue box pageNum = arcpy.GetParameterAsText(0) ddp = mxd.dataDrivenPages arcpy.AddMessage(pageNum) pageID = mxd.dataDrivenPages.getPageIDFromName(pageNum) mxd.dataDrivenPages.currentPageID = pageID #Set layer definition query, this contols the rowcount variable pageFieldValue = pageNum mapLyr.definitionQuery = '"pageNum" = %s' % pageNum #Listing the text elements on the page concatElem1 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat1")[0] concatElem2 = arcpy.mapping.ListLayoutElements(mxd, "TEXT_ELEMENT", "concat2")[0] #Finds the number of features in the map and sets up the lists to evenly distribute into the two text elements/columns rowcount = int(arcpy.GetCount_management("IA_Detail_2010").getOutput(0)) percolumn = round(rowcount / 2.0) count1 = 1 count2 = rowcount #Specifies the features being used for the SearchCursor sortfield = "crash" rows = arcpy.SearchCursor(mapLyr, "", "", "CONCAT") fieldrow = arcpy.SearchCursor(mapLyr, "", "", "pageNum", sortfield + " A") currentpage = "" text_var1 = str() text_var2 = str() #The first for and if block limits the searched rows to the definition query #The seconded/indented for and if block adds the text fields to the text elements for row in fieldrow: if currentpage != row.pageNum: currentpage = row.pageNum for row in rows: if count1 <= percolumn: text_var1 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep) concatElem1.text = text_var1 count1 += 1 elif count2 > percolumn: text_var2 += '{0}{1}'.format(row.getValue("CONCAT"), os.linesep) concatElem2.text = text_var2 count2 - 1 else: pass else: pass #Removed the definition query so all page numbers appear when the script is run next and refresh he layout view mapLyr.definitionQuery = "" arcpy.RefreshActiveView() del mxd, row, rows, rowcount, percolumn, count1, count2
Angemeldete Mitglieder können Beiträge verfassen, Updates folgen und mehr. Neu hier? Registriere ein kostenloses Konto.
Find useful guides, FAQs, and documents to help you navigate and make the most of Esri Community.