I have an excel table with trips where the origin and destination locations are in the same row. I now want to add these locations to a route analysis layer (shortest route analysis) using Python. Each trip has an id. For some trips, more than one row exist (say: the trips has more than one leg, see example).
Do you have an idea how do this with a Python script?
You will need to do convert the table into "two" sets of locations. I can describe the steps and you can automate it in python. You can do this in ArcMap by first adding the excel table. Then use the "Add X Y data" option and create a new point feature class from the first set of coordinates, that is origin_x and origin_y and then repeate the above but using the destination_x and destination_y. Now you can load these one after the other as stops in a Route analysis layer but using the same id mapped to the "RouteName" property. That way, the same row will turn into a single route. You can load in additional points with the same id as more legs of that route. The only thing you have to watch out is the "order". As long as your data is sorted on ID and Leg it should be fine. Try it out in ArcMap and then automate in python using the equivalten GP tools.