Select to view content in your preferred language

Alter time properties of layer using Python?

4374
2
02-04-2015 08:20 AM
BrentKraninger
Emerging Contributor

First a bit of explanation of what I'm trying to do.  We are attempting to automate the creation/publishing to ArcGIS for Server of a new Map Document that contains several time-enabled Mosaic Datasets, each of which will eventually contain a full years worth of 30 minute imagery.  To that effect, we need to be able to reset the time extent (start/end time, and time step) on the new layers. 

So far the only way I've found to do this is with the Arcpy function "UpdateLayerTime".  This function is almost completely useless to someone attempting to do things completely in Python, as it requires the user have a reference layer to set the time properties of the target layer.  Well how do I use Python to set the time properties of THAT layer?  It's a 100% useless function.  Okay, rant over. 

But does anyone know of a way to (using Python NOT in any GUI) set the time properties of a time-enabled layer?

Thanks all!

0 Kudos
2 Replies
DavidChambers1
Deactivated User

Have you considered using the LayerTime object in the ArcPy mapping module? It exposes the time properties for a time-enabled layer.  In order to reset the time extent (start time, end time, time step) on the reference layer you could use python's datetime module in combination with the arcpy.mapping LayerTime object. So ideally the workflow would be to first use the LayerTime object on the reference layer and next re-specify time properties of the target layer with this updated reference layer.  Check out the documentation on it and let me know what you think:

LayerTime (arcpy.mapping)

python datetime module

BrentKraninger
Emerging Contributor

The time attributes on Layer are all read only.  So you can't actually use Python to set them directly.  Attempting to do so yields an attribute error.

0 Kudos