0

enter image description hereI am trying to get ModelBuilder to create a route for each row in a .csv file. Each row has one start and stop locations (Point A and Point B). I need to add both start and stop locations to a network layer to create a route. I then need to delete these stops, and iterate back through, creating a route for each record between each start and stop point. In the Add Locations tool help, I read that the Append Parameter might be what I need to use. In the tool dialog box, there is just a checkbox, but in the Python reference it says

APPEND — Adds the new network analysis objects to the existing set of objects in the selected sublayer.

CLEAR — Deletes the existing network analysis objects and replaces them with the new objects.

I think I need to do both Append and Clear actions to get what I am trying to achieve but it is just a checkbox in ModelBuilder.

Will I need to use Python code to be able to append, then clear, stops in an iterator model?

I am not very strong writing Python Code and was hoping to use ModelBuilder to get what I need.

I added my model builder file for clarification. The problem lies in the Add Locations tool. It only accepts one pair of Lat/Lon coordinates

enter image description here

11
  • Which analysis tool are you using?
    – SMiller
    Commented Nov 28, 2018 at 20:06
  • I assume you mean which Network analysis tool am I using? I am using the Make Route Layer tool.
    – Michael
    Commented Nov 28, 2018 at 20:17
  • 2
    If you are looking at the help file keep scrolling down! Your answer is there under the code section, that is the tool being used in a Python script.
    – Hornbydd
    Commented Nov 28, 2018 at 20:19
  • Yeah I see that but i do not know how to write code in Python. I was hoping someone would know the model builder solution.
    – Michael
    Commented Nov 28, 2018 at 20:25
  • To clarify, if you have 5 start and 4 end points, are you looking for 20 routes? e.g. start1 - end1, start1 - end2 etc?
    – SMiller
    Commented Nov 28, 2018 at 20:41

2 Answers 2

1

1-2. Use Make XY Event Layer to create your start and end points as separate layers. Make sure you specify the spatial reference used for the coordinates. You may need to export these to a shapefile or feature class; test first.

  1. Make the Route Layer

  2. Add an iterator based on the matching unique name for each route. e.g. if the fieldname is "Name", add an iterator for the field "Name" on the start points layer.

  3. Use Add locations from the start points layer based on this iterator -- I think you can make an inline variable and use Select by Attributes. See option 2 in this documentation for inline variable substitution in model builder. Someone else may be able to flush this section out more. For this one, use the option "CLEAR".

  4. Use Add locations from the end points layer based on the iterator. Might need to use Select by Attributes as above. For this one, use the option "APPEND". Make sure this step isn't completed until 6 finishes. (Right click on this step, go to Properties, Preconditions, and check the box for the output from the first Add Locations.)

  5. Solve the route

  6. Export the route polyline. Decide at this time whether you want to have M values (can change in environment settings if you just want the polyline instead of polyline M.) Make sure you give this a unique feature class name.

These resources may help with the advanced Model Builder techniques:

https://www.esri.com/arcgis-blog/products/product/mapping/what-i-wish-i-had-known-about-model-builder-before-i-started-using-it/

http://desktop.arcgis.com/en/arcmap/10.3/analyze/modelbuilder/a-quick-tour-of-advanced-techniques-in-modelbuilder.htm

2
  • Well I can tell you right now a model can only have one iterator. At the least, what you described will take two iterators as I just cant simply add another iterator.
    – Michael
    Commented Nov 29, 2018 at 15:43
  • You only need one iterator.Create a variable from the iterator and pass it through inline to a select or select by attributes. desktop.arcgis.com/en/arcmap/10.3/analyze/modelbuilder/…
    – SMiller
    Commented Nov 29, 2018 at 16:09
0

Wow, so I actually didn't need an Iterator after all. Solution is below. It was using a combination of Clear then Append check boxes that solved the issue.

solution

1
  • 1
    It was the comment where you said to use a combination of first Clear, then Append, checkbox when adding locations that fixed the issue. In the first Add Locations tool make sure the box is unchecked, in the second one, make sure that it is checked. This model does what I need, it produced routes between start and stop locations in one shape file. I could select out individual segments if I chose to going forward. Thanks all for your help!
    – Michael
    Commented Nov 29, 2018 at 16:34

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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