Overlay Route Events - Standalone Python Script with definition queries

926
4
09-23-2020 06:13 AM
CharmaleeSandanayake1
New Contributor III

My org started using Roads and Highways this year and would like to create a standalone python script to run the overlay route events tool. We were able to create a script based on the code here: Overlay Route Events—Location Referencing for Roads and Highways | ArcGIS Desktop 

However, we would like both the LRSN and event layers to have definition queries set on them so that only current roads are output. When I bring the LRSN and event layers to ArcMap, they are automatically queried as follows:

(FromDate is null or FromDate<=CURRENT_TIMESTAMP) and (ToDate is null or ToDate>CURRENT_TIMESTAMP)

Would anyone know how to apply the query in the python before running the overlay route events tool?

Thanks,

Charmalee

0 Kudos
4 Replies
NathanEasley
Esri Regular Contributor

Hi Charmalee,

If you're looking to making a selection on your network and/or events that will be utilized in the overlay, I would suggest taking a look at Make Query Layer (Data Management)—ArcGIS Pro | Documentation.

You mentioned the definition query for time that we automatically put onto layers ((FromDate is null or FromDate<=CURRENT_TIMESTAMP) and (ToDate is null or ToDate>CURRENT_TIMESTAMP)).  I would suggest continuing to utilize some sort of time query when you run the Overlay Events tool as the tool is designed to run against a single time range.

Nathan

ArcGIS Roads and Highways team

0 Kudos
CharmaleeSandanayake1
New Contributor III

Thanks Nathan. I tried creating a query layer in ArcMap using the script from the link you provided. When I  try to input the query layer Road LRS into the Overlay Route Event Tool I get the following error message:

Unable to get Network properties from the LRS Meta Data table.
Unable to parse parameters.
Failed to execute (OverlayRouteEvents).

I did try to run the Overlay Route Event tool both programmatically and within ArcMap. I also tried using the ArcMap Make Query Layer tool and then putting the output query into the Overlay Route Event Tool but get the same result.

Any idea where the error could be coming from?

0 Kudos
CharmaleeSandanayake1
New Contributor III

I had asked our Esri rep about this  previously and she recommended the Make Feature Layer Tool (Make Feature Layer (Data Management)—ArcGIS Pro | Documentation ) or saving layer files of the events and then running the Overlay Route Events tool. Just had to reread the email she had sent months ago.  So far that seems to be working. Thanks for your help.

0 Kudos
NathanEasley
Esri Regular Contributor

Hi Charmalee,

Glad to hear you got the tool working using python.

Nathan

ArcGIS Roads and Highways team

0 Kudos