This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import arcpy, os | |
| outDir= r'C:\MyImageFolder' | |
| mxdPath = r'C:\MyMap.mxd' | |
| mxd = arcpy.mapping.MapDocument(mxdPath) | |
| df = mxd.activeDataFrame | |
| counter = 0 | |
| myTime = df.time.startTime |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #Import python libraries | |
| import arcpy, os | |
| from PyPDF2 import PdfFileWriter, PdfFileReader | |
| #Creates two empty pdf documents | |
| print("Creating pdf document") | |
| myPDFPath = r'C:\MyNewFile.pdf' | |
| myPDFPathArcGIS = os.path.join(os.path.dirname(myPDFPath),'My_Temporary_File.pdf') | |
| myPDFArcGIS = arcpy.mapping.PDFDocumentCreate(myPDFPathArcGIS) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def sequentialByX(lyr, orderFld): | |
| #'lyr' is the name of your layer in ArcMap | |
| #'orderFld' is the name of the field that you want to populate with sequential numbers | |
| #First let's get a list of x coordinates and the corresponding objectid | |
| coordLst = [] | |
| idFld = arcpy.Describe(lyr).OIDFieldName | |
| rows = arcpy.da.SearchCursor(lyr,["SHAPE@X", idFld]) | |
| for row in rows: | |
| coordLst.append([row[0], row[1]]) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def assignSequentialNumbers(lyr, fldID, fldSort): | |
| #lyr = a point layer in your mxd, such as Cities from the example above | |
| #fldID = the field in lyr to which you would like to assign numbers, such as "Rank" in example above | |
| #fldSort = the field in lyr by which you would like to sort, such as "Name" in the example above | |
| with arcpy.da.SearchCursor(lyr, fldSort) as rows: | |
| myLst = [] | |
| for row in rows: | |
| myLst.append(row[0]) | |
| myLst.sort() | |
| myDict = {} |