Does Pro Py have a method to access the time property in a time-enabled layer?

606
1
Jump to solution
07-05-2018 01:17 PM
ThomasColson
MVP Frequent Contributor

From DataFrameTime—Help | ArcGIS Desktop, the following example exports each "Time Frame" as a unique file:

import arcpy
import os

mxd = arcpy.mapping.MapDocument(r"C:\Project\Project.mxd")
df = arcpy.mapping.ListDataFrames(mxd, "Traffic Analysis")[0]
df.time.currentTime = df.time.startTime

while df.time.currentTime <= df.time.endTime:
    # 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 = str(df.time.currentTime).split(" ")[0] + ".png"
    arcpy.mapping.ExportToPNG(mxd, os.path.join(r"C:\Project\Output", fileName), df)
    df.time.currentTime = df.time.currentTime + df.time.timeStepInterval
del mxd

From Migrating from arcpy.mapping to ArcGIS Pro—ArcPy | ArcGIS Desktop  I see 

p = arcpy.mp.ArcGISProject("CURRENT")
m = p.listMaps("Yosemite National Park")[0]
for lyr in m.listLayers():
    if lyr.supports("SHOWLABELS"):
       lblClasses = lyr.listLabelClasses()

as an example of how to access the map part, but I'm not seeing any documentation or examples on how to access the time property, if a Pro map has a time-enabled layer. In context, I'm working  Working with a multidimensional raster layer—ArcGIS Pro | ArcGIS Desktop where I have some 100 rasters, each with a time stamp, and I want to export each "Step" as it's own JPEG. 

0 Kudos
1 Solution

Accepted Solutions
JoshuaBixby
MVP Esteemed Contributor

Another interesting/odd (and yet not completely surprising) aspect is that ArcMap has LayerTime—Help | ArcGIS Desktop , but no such equivalent exists in Pro as far as I can tell.

View solution in original post

1 Reply
JoshuaBixby
MVP Esteemed Contributor

Another interesting/odd (and yet not completely surprising) aspect is that ArcMap has LayerTime—Help | ArcGIS Desktop , but no such equivalent exists in Pro as far as I can tell.