In ArcGIS 10.3, I have a point dataset of Students with which college they study at. I need to find out can I run a network analysis on the entire dataset which will find the distance of each point to the facility stated in the 'College' attributes without running for each college individually?

I have a dataset of students and a separate dataset for the colleges they go to. I know I can do it by selecting each college individually however was wondering if there is a way to do it all at once?


This kind of problem is solved by using the Route, Closest Facility, or OD Cost Matrix solver in Network Analyst. However, you cannot choose beforehand what college each student will be "routed" to.

There is an ArcGIS Idea for adding a field called facility to essentially generate a matrix of origin-destination with pre-defined destination.

You would need to build a model or do some Python scripting. You would need essentially run the Closest Facility multiple times (I would recommend this one for this task) each time filtering out all of colleges except the one which every group of students go to. You can think of using GROUP BY in SQL. The workflow would be:

  1. Select all students grouped by a college and add them as incidents.
  2. Select the college and add as facility.
  3. Solve and append the results into a final routes feature class.
  4. Repeat the steps 1-3 choosing another college.

I've written a similar task before with arcpy, and it was about 30 lines of code.

I suggest taking a look at this sample. It provides information on how to do every step of the workflow I've described.

| improve this answer | |

I don't know the network analyst well, but two remarks to see if i understand you right:

  1. the relationship of students to college is m:1, so many students share one college
  2. you have both the location of the students and the location of the college

if true i would divide the table into two: one with the students and one with colleges. And then try further...

| improve this answer | |

If you can use Python / arcpy little bit, it could be possible to make iterative selection on points (students) by the college that they are studiing with selected currnet college (I assume it is another shp with colleges).

Then use Near tool to find distances.

After that, new selection for next college and so on.


I suppose that both shapefiles (colleges and students) has filed with colleges names that has the same name in both shp.

I didn't test this script, but I could wotk that way.

import arcpy

# Set workspace
arcpy.env.workspace = r"path_to_workspace"

# Set variables
college_shape = "layer_with_colleges.shp"
student_shape = "layer_with_students.shp"

# Create cursor to find college names
field = "name_of_field" # field in attribute table with colleges
cursor = arcpy.da.SearchCursor(college_shape, [field])
for row in cursor:
    sql = '"' + field + '" = ' + row[0] # make sql
    # Select college fit specific name
    arcpy.SelectLayerByAttribute_management(college_shape, "NEW_SELECTION", sql)
    # Select students with specific college
    arcpy.SelectLayerByAttribute_management(student_shape, "NEW_SELECTION", sql)
    # Run Near tool
    arcpy.Near_analysis(student_shape, [college_shape])
| improve this answer | |
  • Thanks for both answers. Unfortunately I can't use Python yet. (on my 'to learn' list.) I am able to do it using "Nearest Facility" by selection by attributes, I was just wondering was there an option to process all in one go. – Wilmac Feb 4 '16 at 10:55
  • I can help you with Python code, it could be easy, if you want. – david_p Feb 4 '16 at 11:31
  • Does the 'Near Tool' use a network? Thanks that would be great. – Wilmac Feb 4 '16 at 11:37
  • I think Near tool is from Analysis tools. See edit in answer. – david_p Feb 4 '16 at 11:57

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.