How to create a time-enabled layer to work with GeoAnalytics Desktop tools for a standalone Python script

318
1
Jump to solution
04-21-2021 03:17 PM
Labels (2)
ET
by
New Contributor

Hello - Any guidance on how to create a time-enabled layer to work with GeoAnalytics Desktop tools (ArcGIS Pro 2.7.0) in a standalone Python script? I see the code samples for the Reconstruct Tracks and Find Dwell Locations tools, but when I try to run these samples, cannot seem to find a way to set or make the input layer time-enabled. I'd like to run my script without having to open a map.

Any suggestions? 

0 Kudos
1 Solution

Accepted Solutions
BethanyScottEsri
New Contributor

Hey ET,

Thank you for your question.

I've added a sample script below that will set time on the input features you want to use. However, you will have to open your map to prepare the data initially. After that first step in the map, you'll be able to use the data in a standalone Python script.

import arcpy

# To create the lyrx: add your layer to a map, open the layer properties and enable time, then right-click on the layer and choose to Share As Layer File
input_lyrx = r'C:\data\layer_files\L0ubersf_subset.lyrx'

# Make Feature Layer converts the lyrx to features
make_feature_layer_output = arcpy.MakeFeatureLayer_management(input_lyrx, "make_feature_layer_output")

# Apply symbology sets the time on the feature layer based on the lyrx file definition
arcpy.ApplySymbologyFromLayer_management(make_feature_layer_output, input_lyrx)

# Now you can use the make feature layer output as time enabled points
arcpy.gapro.FindDwellLocations(input_features=make_feature_layer_output,
                               output=r'C:\data\output.gdb\MyOutputLayerName',
                               track_fields="id",
                               distance_method="PLANAR",
                               distance_tolerance="250 Feet",
                               time_tolerance="3 Minutes",
                               output_type="DWELL_CONVEX_HULLS",
                               summary_statistics="latitude SUM;latitude VAR")

 

Please let me know if this works for you or if you have any questions.

Thank you!

Bethany

View solution in original post

1 Reply
BethanyScottEsri
New Contributor

Hey ET,

Thank you for your question.

I've added a sample script below that will set time on the input features you want to use. However, you will have to open your map to prepare the data initially. After that first step in the map, you'll be able to use the data in a standalone Python script.

import arcpy

# To create the lyrx: add your layer to a map, open the layer properties and enable time, then right-click on the layer and choose to Share As Layer File
input_lyrx = r'C:\data\layer_files\L0ubersf_subset.lyrx'

# Make Feature Layer converts the lyrx to features
make_feature_layer_output = arcpy.MakeFeatureLayer_management(input_lyrx, "make_feature_layer_output")

# Apply symbology sets the time on the feature layer based on the lyrx file definition
arcpy.ApplySymbologyFromLayer_management(make_feature_layer_output, input_lyrx)

# Now you can use the make feature layer output as time enabled points
arcpy.gapro.FindDwellLocations(input_features=make_feature_layer_output,
                               output=r'C:\data\output.gdb\MyOutputLayerName',
                               track_fields="id",
                               distance_method="PLANAR",
                               distance_tolerance="250 Feet",
                               time_tolerance="3 Minutes",
                               output_type="DWELL_CONVEX_HULLS",
                               summary_statistics="latitude SUM;latitude VAR")

 

Please let me know if this works for you or if you have any questions.

Thank you!

Bethany

View solution in original post