I have been working on finding the shortest routes from a series of residential blocks (a shapefile with polygon centroids) to a a number of recreational areas. I have a total of 9 resulting OD cost matrices (Playing fields within 1000m, Playing fields within 600m, Playing fields within 300m, and then recreational areas and green recreational areas all over again).

Since each destination polygon (playing fields, gren rec areas, rec areas) has multiple points of entry, the OD cost matrix contains multiple routes to each destination. I only need the shortest of those routes.

I have therefore built a model to go through each of the OD cost matrices and select the shortest route from each block to each listed destination.

I've only done about three models before this, and I feel it is quite crude.

The model is comprised of the following:

Part 1 - Iterates through the OD Cost Matrix files Part 2 - Nested in Part 1 -Exports all routes from a single block to a separate shapefile using Iterate row selection and Copy feature Part 3 - nested in Part 2 - Here the model iterated through the destination ID's (each destination polygon has its own id, as do all its perimeter destination points) , selects all entries with the same destination ID's and saves them to a new shapefile. Then it takes that shapefile, uses 'Calculate value' to select the smallest distance value, and using another Select tool with the following SQL query selects the entry with the smallest distance and saves it as a separate shapefile.

"Total_Leng" = %output_value%

where %output_value% is the value passed by the 'Calculate value' tool

This last selection tool takes from 3 to 6 minutes per iteration. The model has been running for 6 days now, and has only gone through 600 of 2400 entries from the FIRST of nine shapefiles.

The biggest problem is Part 3 I am sure there is a more efficient alternative to saving selections as shapefiles. I would think there would be an option to keep selections in memory, but I really cannot find it and I read that model builder isn't so great at working from memory.

Any suggestions as to how I can improve performance? The results of this model are good, but it is simply too slow. I have been searching for similar problems but I haven't found anything specific. Maybe someone here has any suggestions? I know I could do a better job with Python but I cannot afford the time to get into Python beyond the basics (which is what I know - the very basics).

I've added images of the model below, I could also add the python scripts if required.

Step 1 Step 2 Step 3

1 Answer 1


I will answer my own question. After some more research I found that the answer is to use feature layers (see ESRI's help page)rather than saving intermediate results in shapefiles. The select tool which was taking up to 6-7 minutes is now taking around 0.9 seconds.

Quite the difference!

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.