# Is there a function like XY-to-Line that calculates distance along a network for many XY pairs?

So:
I have a set of XY origins and a set of destinations. I know that XY to Line will give me the Euclidian distance between a given set of origins and destinations, and that an ODS cost matrix can return the distance to a given set of destinations for a given set of origins along a network. Unfortunately, an ODS cost matrix seems like a bad decision given the size of the data set I'm working with. So, I'm looking for a function that is exactly like XY to Line, but that will give me distance along a network between many sets of two points, instead of outputting Euclidian distance.

Any ideas?

PS
Why does the size of my file factor into this? It seems to me that:
I am calculating the distance between (households of people on food stamps) to (retailers that accept food stamps). If I calculated the distance between every food stamp recipient in our sample (~55,000) to every retailer in our sample (700) for every month that we are concerned with (17), the calculations start to add up (~655 million). But if I only calculate the distance between the recipients (55,000) and the stores they actually shop at (about 5 per household), it gets a lot more managable, processing time-wise (~4.7 million).

One method is to use Route Analysis. It's not immediately obvious why since Route Analysis only allows you to input one "Stops" feature class instead of two feature classes for origin and destination. However, route analysis will create unique routes for every group of features with the same ID. In other words, route analysis will produce a single, unique route for all origin and destination points that share a unique ID. To do this, you need to bring your origin and destination points into a single feature class that Route Analysis will read as your "Stops." See step-by-step below:

1. Make sure your data is projected.

2. Merge your origin and destinations feature classes into one. In order to do that, create identical fields in both feature classes that contains a unique ID for every corresponding origin and destination. For example, Joe gets his food stamps from 7-Eleven on 125th Street. In your households feature class, you'll assign Joe a "1" in the common ID field. In your destination feature class, you'll assign the 7-Eleven address a "1" in the corresponding field. Every household and retailer entry must have a unique matched ID, even if, for example, that 7-Eleven services 20 households, or a household frequents several retailers.

Also note that the order in which you list your feature classes during the merge will determine the sequence of the route. Therefore, list the origin feature classes first.

1. Make a Route Analysis layer with all necessary adjustments. Scroll down to "Accumulators" and check "Length." This will include route distance in the output.

2. Add your merged feature class as locations to "Stops." Set both the "Name" and "RouteName" fields as the unique ID field. This is crucial. The "Name" field appears in the "Routes" output of the route analysis; the "Route Name" field is where the analysis will make your route matches and establish unique routes for each pair. Make sure "Find closest among all classes" is unchecked. Make the rest of your adjustments in the dialogue box.

(for further explanation, scroll down to the "RouteName" field in the "Stop Properties" box on the ESRI Route Analysis help page: http://resources.arcgis.com/en/help/main/10.1/index.html#/Route_analysis/004700000045000000/ )

1. Solve your analysis. You should get a set of unique routes from households to retailers.

Assuming you are using ArcGIS (you don't actually say which GIS you are using) then this is a network analyst problem. Sounds like you want the shortest route between "A" and "B" along a road network. Well first you need network analyst installed and licensed then you need to read the Help file, get familiar with the terminology like routes, stops and weights. There are walk throughs for you to learn the basics.

• Sorry - I'm using ArcGIS, yep. I have network analyst installed, and I'm relatively familiar with it (for instance, an ODS cost matrix is a type of problem that network analyst solves), but it doesn't seem like any of the problems network analyst normally solves logistically works the way I need it to (i.e., find the shortest route between many As and many Bs along a route, a la XY to Line). – gschwartz Nov 27 '13 at 3:43