1

I am trying to create a toolbox that will execute 'Locate Features Along Routes' in multiple layers and in two active maps in ArcGIS Pro. One map contains linear features to be located, the other contains point features to be located. I believe the out_table is overwriting the previous table as the script iterates over each layer in the map. I believe I need to add lines to the script that would ensure a unique table is generated for each iteration of locate features along routes.

Code example below

Code here:

aprx = arcpy.mp.ArcGISProject("CURRENT") maps = aprx.listMaps() for map in maps: print("\nCurrent map: {}".format(map.name)) layers = map.listLayers() for lyr in layers: print("Layer: {} Broken?: {}".format(lyr.name,lyr.isBroken)) map1 = maps[0] map2 = maps[1] in_routes = arcpy.GetParameterAsText(0) out_table = arcpy.GetParameterAsText(1) for lyr in map1.listLayers(): print (" " + lyr.name) arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "0 Feet", out_table + "//" + "{}_Located".format(lyr), "MapRouteId Line PointLocation", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") for lyr in map2.listLayers(): print (" " + lyr.name) arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "10 Feet", out_table + "//" + "{}_Located".format(lyr), "RouteId Point FMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") 

1 Answer 1

1

If you would like a new table name for each iteration of the loops you could do something like this:

for i,lyr in enumerate(map1.listLayers()): print (" " + lyr.name) arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "0 Feet", out_table + "//" + "{}_Located_{}".format(lyr,i), "MapRouteId Line PointLocation", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON") 

It uses the layer index for the out table name.

0

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.