0

I have a toolbox that is executing locate features along routes for a number of layers in a map. For each iteration of the locate features along routes I am expecting a stand alone table for each of the located layers. In my current script the out_table is identified as a parameter. I have it currently set as a Workspace | Required | Input, however the tool seems to attempt to write the tables to my aprx default gdb. Additionally, the tool seems to get stuck on the second layer in my map.

Is this a parameter problem or a script problem or both?

Code Example:

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]

out_table = arcpy.GetParameterAsText(0)
in_routes = arcpy.GetParameterAsText(1)


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 FMEAS TMEAS", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")

for i,lyr in enumerate(map2.listLayers()):
    print (" " + lyr.name)
    arcpy.lr.LocateFeaturesAlongRoutes(lyr, in_routes, "RouteId", "10 Feet", out_table + "//" + "{}Located{}".format(lyr,i), "MapRouteId Point StationPoint", "FIRST", "DISTANCE", "ZERO", "FIELDS", "M_DIRECTON")```
1
  • Can you comment out the LocateFeaturesAlongRoutes and just print the values "out_table + "//" + "{}Located{}".format(lyr,i)"? There might be something wonky going on when the string gets built. Also, you might have better luck using os.path.join to build out file paths.
    – Brennan
    Aug 11 at 19:59

1 Answer 1

1

It you look at the code samples on the help page for this tool they all set the workspace rather than build the full path to the output table as you have. I know some tools (certainly in ArcMap) function with the environment setting workspace set, so try that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.