Hello everyone,
I am currently trying to connect temporal data from a particular data table from ArcPy to my XY data and am having a bit of trouble. This forum post got me a good starting point, but I'm a bit stumped from here.
I am essentially trying to replicate the functionality when you do the following actions:
This generates a time slider on top of the data.
I manually investigated the data fields using the Python window and tried to reconstruct the code necessary to reproduce it from scratch. I came up with the following code, where "example1" is a data table that has the fields "latitude", "longitude", and "timestamp." The "timestamp" field is in format "yyyyMMdd."
import arcpy
p = arcpy.mp.ArcGISProject("CURRENT)
m = p.listMaps("Map)[0]
l = m.listLayers("example")[0]
l_cim = l.getDefinition("V2")
ft = l_cim.featureTable
ft.timeFields = arcpy.cim.CIMVectorLayers.CIMTimeTableDefinition(
startTimeField="timestamp",
timeValueFormat="yyyyMMdd"
)
timeReference = arcpy.cim.CIMExternal.TimeReference()
customTimeExtent = arcpy.cim.CIMExternal.TimeExtent()
ft.timeDefinition = arcpy.cim.CIMVectorLayers.CIMTimeDataDefinition(
useTime=True,
timeReference=timeReference,
timeExtentCanChange=False,
hasLiveData=False,
customTimeExtent=customTimeExtent
)
ft.timeDisplayDefinition = arcpy.cim.CIMVectorLayers.CIMTimeDisplayDefinition(
cumulative=False,
timeInterval=10,
timeIntervalUnits='esriTimeUnitsUnknown',
timeOffset=0.0,
timeOffsetUnits='esriTimeUnitsDays',
uniqueTimes=[]
)
ft.timeDimensionFields = arcpy.cim.CIMVectorLayers.CIMTimeDimensionDefinition()
l_cim.featureTable = ft
l.setDefinition(l_cim)
l.enable_time()
p.save()
From what I can tell, this creates a CIM that matches the corresponding CIM that was created when I made a Time Slider in the UI. I checked this through the interactive Python window in ArcGIS Pro. When I do this through the Python script, a Time Slider is created, but it does not connect with the data. When I disable time in the UI, the points appear, but when I enable time, everything disappears.
Can anyone direct me to any documentation for this? I'm a bit stuck right now. Thanks.