Zoom to a user specified routeId/mileage

File uploaded by vitale232 on Dec 21, 2018
Version 1Show Document
  • View in full screen mode

Hello RHUG,

 

Much of my work at the New York State DOT currently centers around using Roads and Highways. This past week, I've been going through a former colleague's notes on some routes that need edited. His notes include a route ID and the mileage of where the issue is present. Given that some of our routes are > 40 miles and that most of the edits are in urban areas, I've been spending way more time panning the map than seemed reasonable.

 

I was hopeful that there was built-in functionality to zoom the map to a specified route ID and mileage, but I can't find anything. So I built an ArcGIS Python Toolbox to accomplish this task.

 

I've attached a zip directory that contains the .pyt file, it's associated documentation as .xml, and a .py file so that you can easily see the code in a syntax-highlighted editor. If you extract this zip in an ArcGIS-connected folder, the tool should show up in the Catalog.

 

I originally thought it should be simple enough to use the Make Route Event Layer (Location Referencing Toolbox) GP tool to make a single point event on the route and zoom to that point, but the tool is just too slow to operate. Here's the workflow I settled on:

  1. Use the Feature Vertices to Points (Data Management Toolbox) GP tool to get the input route ID's vertices as points
  2. Use the Add XY (Data Management Toolbox) GP tool to add the M values to the point data attribute table
  3. Find the vertex that has an m-value closest to the user's input "zoom-to mileage"
  4. Move the active .mxd file's Data Frame to the extent of the vertex, and zoom the map to a hard-coded scale value

 

Some quirks of the ZoomToMilepoint toolbox:

  • The tool clears the currently selected features from your input routes layer by default. To maintain your collection set, click "Use selected features" and ensure that the input Route ID is within the selection set. WARNING: This is very different than the standard GP tools' handling of selection sets.
  • The nature of this workflow means that longer routes (where you're more likely to desire this tool) process a bit slower. On my machine at NYSDOT, it usually runs in 10-25 seconds on our interstates (which are built in R&H per county).
  • It won't zoom your map to the precise input value, but rather it will snap you to the vertex closest to the input value. If your routes have very few vertices per mile, you'll find this way less useful.
  • There are two hard-coded items that are specific to NYSDOT. In the updateParameters method, arcpy.mapping.ListLayers has a wildcard expression that searches for the name of our enterprise LRS (*Milepoint*). In the same method, our route ID field name is also hard-coded (ROUTE_ID). If you replace these values with the correct values for your environment, hopefully the LRS Inputs will autopopulate in the tool.
  • Tweak the df.scale = 1800 line of the .pyt file if you don't like the default zoom level
  • Input Routes does not attempt to autopopulate until you've typed in a Route ID. It's the most stable way I could figure.
  • Developed on ArcGIS 10.5.1, tested on a whopping 2 machines

 

Hopefully a better-performing version of this functionality shows up in R&H at some point. In the meantime, I'd love any feedback you may have.

 

Happy holidays,

Andrew

Screenshot of zoom to milepoint python toolbox for esri arcgis roads and highways, which zooms the map to the input route ID and mileage

Outcomes