I read over the solution in Distance between points along polyline ArcGIS for Desktop? and I have a slight variation of that problem:
I need to find the distance of each red point (transformers) from the yellow point (the main generator) along the distribution network.
Each transformer receives power from the main generator. I've included a screenshot of (a) large-scale view and (b) small-scale view (green box). Each line has a distance attribute in feet, which I've labeled. The lines do not inherently "flow" toward or away from the generator, directionality is arbitrary (see blue circled).
A line exists between each transformer, so we never need to find a "midpoint" distance per-se, transformers always intersect line endpoints/startpoints.
If there are multiple routes to reach the main generator, we need to find the the shortest route (I believe there is always only one conceivable route from transformer to generator in this data, but just in case...).
What is the best way to go about this?
- Modify the "chainage" code mentioned above to process multiple line segments en route to a specific point an unknown distance away? Challenge is how would script know which path to take when the network forks en route to the generator?
- Create a script to perform some sort of "Select by Location" ==> select network lines that intersect generator, then select network lines that intersect selected network lines recursively, causing the whole selection to propagate upon each iteration until the whole thing intersects the transformer of interest, then whittle the selection down to the route between the transformer of interest and generator (somehow), and sum the distances of lines along the route?
- Read up on Linear Referencing and apply it here. I have certainly never used Linear Referencing in my career so far, but if M-enabling the data will solve my problems, I will gladly do due diligence.
- Pretend our data is in Google Maps and use the Google Maps Distance Matrix API via Python wrapper. The Origin is the generator. The List of Destinations would be all the transformers. Get distance for each route. This option is obviously facetious, but could we use Network Analyst to do some of the logic above?