Select to view content in your preferred language

add origin & destination locations from the same row to a route analysis layer

533
3
09-01-2010 07:46 AM
MartinaRagettli
Emerging Contributor
Hi

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?


id      leg     origin_x     origin_y    destination_x     destination_y
------------------------------------------------------------------------
1       1      x00001      y00001        x00002           y00002
1       2      x00002      y00002        x00003           y00003
1       3      x00003      y00003        x00004           y00004

Note: the origin coordinates of leg 2 and 3 are the same as for the destination of the previous leg.

Thanks
Tags (2)
0 Kudos
3 Replies
RamB
by
Frequent Contributor
Hi,

This is very easy. Do you mean you want to add only the final and initial point of the trip and use shortest path analysis for finding the trip routes ?

This very table can be used, provided you use Node IDs (or coordinates). Do you already have a solution? Else I can tell you how.

Sriram
Botswana/ Rwanda
0 Kudos
JaySandhu
Esri Regular Contributor
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.

Jay Sandhu
0 Kudos
RamB
by
Frequent Contributor
Jay is right. I would suggest the same.
0 Kudos