POST
|
I was able to figure it out. I'm almost positive it was a leap year problem so I hard coded a time interval for 5 years using 1826.25 days (365.25 * 5). Now the dynamic text updates correctly. import arcpy, datetime
mxd = arcpy.mapping.MapDocument(r"C:\GIS_data\mxds\ytf.mxd")
df = arcpy.mapping.ListDataFrames(mxd)[0]
df.time.currentTime = datetime.datetime(1961,01,01)
endTime = datetime.datetime(2010,01,01)
interval = datetime.timedelta(days=1826.25)
#added "+ df.time.timeStepInterval" to the end of the while statement because
#the final year group 2010 was getting cut off
while df.time.currentTime <= df.time.endTime + interval:
#An example str(newTime) would be: "2008-12-29 02:19:59"
#The following line splits the string at the space and takes the first
#item in the resulting string.
fileName = "ytf_fall_" + str(df.time.currentTime).split("-")[0] + ".png"
arcpy.mapping.ExportToPNG(mxd, r"C:\GIS_data\media\ytf\\" + fileName)
df.time.currentTime = df.time.currentTime + interval
print fileName
del mxd
... View more
03-08-2011
11:59 AM
|
0
|
0
|
180
|
POST
|
Hi- I'm using the ESRI sample code (modified below) to export a mxd to a series of .PNG files. I'm having problems with the dynamic text associated with the layers. In arcmap I can use the time slider and the text appears correctly - changing by 5 years for each .PNG. But when I export it using the python code it changes the dynamic time text as the time series advances - I think it may have something to do with leap years but I'm not sure. In the .PNG files I'm displaying dynamic text ("time.date" format = "MMM yyyy") and what happens as the time series advances is that at first it shows correctly as Jan 1961 to Jan 1966, Jan 1966 to Jan 1971, Jan 1971 to Jan 1976 but then to Dec 1975 to Dec 1980 - should be Jan 1976 to Jan 1981. I've tried hard coding the py.script using datetime.timedelta(days=1825) but I get similar problems. I just don't understand why it works in ArcMap but not when exporting. Any help or thoughts would be greatly appreciated. here is the code. import arcpy, datetime mxd = arcpy.mapping.MapDocument(r"C:\GIS_data\mxds\ytf.mxd") df = arcpy.mapping.ListDataFrames(mxd)[0] df.time.currentTime = datetime.datetime(1961,01,01) while df.time.currentTime <= df.time.endTime + df.time.timeStepInterval: #An example str(newTime) would be: "2008-12-29 02:19:59" #The following line splits the string at the first - and takes the first #item in the resulting string. fileName = "YF2_" + str(df.time.currentTime).split("-")[0] + ".png" arcpy.mapping.ExportToPNG(mxd, r"C:\GIS_data\media\ytf\\" + fileName) df.time.currentTime = df.time.currentTime + df.time.timeStepInterval print fileName del mxd
... View more
03-08-2011
05:07 AM
|
0
|
1
|
629
|
POST
|
Hi- I'm not sure how that would help. I'm probably just not following your logic but here is what I'm try to do with some examples: It is simple I think - just combine listing a bunch of pdfs from a folder and appending those pdfs in the list to a new single pdf. Here is the first part: import arcpy # Set the workspace. arcpy.env.workspace = r"C:\output" # List all of the pdf files in the output folder. # pdfList is a Python List returned from the ListFiles function. pdfList = arcpy.ListFiles("*.pdf") # Iterate through the fields and print the name of each # field to the Interactive Window. for pdf in pdfList: print pdf and here is the second part: import arcpy, os #Set file name and remove if it already exists pdfPath = r"C:\output\TimeSeries.pdf" if os.path.exists(pdfPath): os.remove(pdfPath) #Create the file and append pages pdfDoc = arcpy.mapping.PDFDocumentCreate(pdfPath) pdfDoc.appendPages(r"C:\output\1991.pdf") pdfDoc.appendPages(r"C:\output\1992.pdf") pdfDoc.appendPages(r"C:\output\1993.pdf") pdfDoc.appendPages(r"C:\output\1994.pdf") pdfDoc.appendPages(r"C:\output\1995.pdf") #Commit changes and delete variable reference pdfDoc.saveAndClose() del pdfDoc
... View more
02-14-2011
04:49 AM
|
0
|
0
|
776
|
POST
|
Hi I'm trying to figure out if I can append a bunch of pdfs into a single pdf document. So I can append the files if I spell out the path and file name of each pdf using pdfDoc.appendPages. I can also list the pdf files that I have in a folder arcpy.ListFiles("*.pdf"). Now if I could just combine the two functions - so that I'm listing all the pdfs in a folder and then appending them to a new single pdf. Thanks in advance. chad
... View more
02-11-2011
11:47 AM
|
0
|
4
|
4733
|
Online Status |
Offline
|
Date Last Visited |
11-11-2020
02:23 AM
|