# Calculate Statistics along a Linear Feature

I have a linear feature class (road network) that is split into segments less than 2 miles in length. Each segment is assigned a value. I want to calculate a distance weighted sum in some manner such as the following:

1. Calculate midpoint of each segment
2. Search X distance units along the linear feature the segment belongs to and sum all values within the search distance with distance weighting (fractional multiplier of each value based on defined distance bins)
3. Return this weighted sum to each segment as a field value

I know how to do 1 and 3, but I'm stumped on how to accomplish 2. Usual methods for calculating spatial statistics ignore geometry and search in a full circle. I want to only search along the linear feature the segment is a part of.

• Which GIS environment are you using? May 24, 2016 at 14:54
• I'm using ArcGIS 10.2.2 and QGIS 2.14.1, but I'm open to using any open source or free application or script that can accomplish this. May 24, 2016 at 15:00
• are you familiar with python? You can accomplish your second goal by accessing the geometry object and using positionAlongLine (desktop.arcgis.com/en/arcmap/10.3/analyze/arcpy-classes/…) in a loop.
– crld
May 24, 2016 at 15:43
• crld, will that work cross-segment? May 24, 2016 at 15:44

If this is a linear referenced network then create an event table with two measures (i.e., the midpoint measure you calculate in step 1 and a second measure at X distance offset from the midpoint measure). Then if the values you want to sum are also events then you can merge the event tables using Overlay Route Events. This will only merge events on the same route.

• Attempting this; I'll let you know how it goes. May 24, 2016 at 18:13
• I have no experience with Linear Referencing, so I couldn't figure out how to do this. Can you provide a more detailed explanation? May 26, 2016 at 18:03
• I assumed you had linear referenced Routes established, since you or someone else put a linear-referencing tag on your post. If that is not the case, you have to start with the Create Routes tool. It sounds like you have a Route ID value for the segments you described. Measures would be based on length (in native units or you can adjust them to other unit lengths). Calculate Begin, End and Mid [(Begin + End)/2] Measures on the routes and export as a table to create events for each route. Add another column for the offset from MID. Locate Features Along Route other events you want to sum. May 26, 2016 at 18:57
• I have an ID for most of the routes (identical for each segment participating in the route), but a portion of the routes are generic and lack any distinguishing information. Do I need to create a unique identifier before I can create routes? May 26, 2016 at 19:29
• Yes you need each segment to have a Route ID. If each segment is supposed to create its own Route you can just create a Long field and calc the ObjectID of the segments into it. However, Routes are not limited to a single original segment and can be built from multiple segments that all have the same Route ID if you need them to chain together. In a Road Network you typically want to follow a single road name and not create branched routes, since that makes the measures complex and not unique. Please provide a picture of what you are trying to weight and sum, since it is not clear. May 26, 2016 at 20:35

I ended up taking this a completely different direction... In ArcMap 10.4:

• Dissolve the road network on Unique Route ID.
• Intersect with dissolved road network as input and points as output
• Split dissolved road network at point using the intersect output
• Build network dataset with cost/impedance functions
• Generate Network Spatial Weights Matrix (Spatial Statistics)
• Convert spatial weights matrix to table (Spatial Statisticts)
• Perform summary statistics on output table to get sums for each segment OID
• Join summary statistics output to split road network
• Run Optimized Hot Spot Analysis using the split road network, the network spatial weights matrix as the spatial constraint, and the network weight sum as the analysis field
• A local autocorrelation statistic on a linear feature, without modification to a 1D approximation, will be quite invalid. A spatial weights matrix Wij constrained to a network, linear dependence, is not adequate without modification of the statistic and its associated null. Apr 20, 2017 at 22:57
• @JeffreyEvans, thanks for the information. Do you have any reference material I can read, such as journal articles? Apr 21, 2017 at 15:01
• You are violating underlying assumptions of the statistic so, review the primary literature on Moran's-I and LISA. You could look at Oakbe's work on network K and KED statistics implemented in SANET. There are numerous papers on the subject of autocorrelation and point pattern analysis along linear features, such as: Spooner P.G., Lunt I.D., Okabe A. and Shiode S. (2004) Spatial analysis of roadside Acacia populations on a road network using the network K-function, Landscape Ecology, 19(5), 491-499. Apr 21, 2017 at 15:31
• Are you familiar with the paper by Nie, et al, regarding network-constrained spatial analysis in Sustainability? mdpi.com/2071-1050/7/3/2662/htm Apr 22, 2017 at 17:45