# Calculating Cumulative Distance (incorporating slope) of Line Feature Using ArcGIS for Desktop?

In ArcMap, when creating a line feature class within a geodatabase, the length of each record is automatically derived upon creation. This length is based on a distance measurement for a planar surface. Let us say, however, that the line feature is meant to represent an entity in an area with high topographic relief.

• Wouldn't the actual length of that line be different than the result from this planar measurement?
• Wouldn't the cumulative length of a line be longer than the planar distance measurement anytime the line does not sit on a planar surface?
• How much of a difference is there between the planar and cumulative length measurements?

A distance calculation on a sloping surface is different than that on a planar surface. This appears to be a latent danger that many may not consider, although it is most important when a project requires high quality measurements and/or when the topographic relief is great. The difference between planar distance and cumulative distance appears to be independent of the distance involved. This is revealed in the table below.

A cumulative distance (i.e., one that incorporates slope in its measurement), and the difference between it and a planar distance, may be derived using ArcMap. The following steps demonstrate one way this may be done.

• Acquire a DEM that overlaps the line feature of interest.
• Using the "Slope" tool, derive the slope of this DEM in degrees.
• Using the "Int" tool, convert this slope raster so that it contains an integer pixel type.
• Using the "Raster to Polygon" tool, convert this new slope raster to a polygon using the slope value in the "field" option (ensure simply polygons in not selected).
• Using the "Intersect" tool, split your line into segments containing unique slope. Input features will be the line feature class of interest and the slope polygon feature class. The figure below displays the slope polygon and the intersect output line feature class. Notice that a line that is attributed with slope has now been created. ArcMap also automatically derives the SHAPE_length for geodatabase feaure classes. The variables of SHAPE_length and slope (GRIDCODE in intersect outout) serve as input for the trigonometric function described below.

• Create a new field in the attribute table of the output from the intersect operation. The calculation of this field will be based on the trigonometric function cos θ = A/H (variables are described in figure below). The side O was derived from the DEM and was used in the earlier step to derive slope.

• Enter and run the following equation in the field calculator for the newly created field. Note GRIDCODE is multiplied by pi/180 (approx. 0.01745) in order to set the input to the cosine function to degrees as opposed to the using the default, which is radians.

[Shape_Length] /Cos ((0.01745 * [GRIDCODE]) )

The sum of the derived values may be used to determine the cumulative distance of the line feature of interest. The table below demonstrates how this value changes with regards to changes in distance and slope. Note that the "Difference" column displays the difference between the a horizontal and cumulative distance calculations.

Lastly, one should consider that the slope value attributed to the line is the average slope of the cells containing a given segment of the line. This may not reflect the actual slope of a the line feature being represented (e.g., a road running through a roadcut.) A DEM with a high spatial resolution may, however, record such detail.

• Interpolate shape and add geometry do it on the fly Jul 24, 2016 at 18:30
• Moreover your solution is incorrect. Consider contour line which is flat by default. Depending on contours density it will grow in length Jul 24, 2016 at 19:33
• Thank you @FelixIP. Using the Interpolate Shape tool and calculating geometry does provide a similar solution to that provided by the workflow I describe above. Jul 25, 2016 at 11:18
• Incorrect? Will you explain? I suggest using slope derived directly from a DEM. Using contours may add further generalization, although I do not know how you intend to incorporate them. Jul 25, 2016 at 11:22
• If you have a route with XYZM coordinates I have built an Add In that lets you assign the M values of each node based on the 3D length of the line so that the last measure is the cumulative length in all 3 dimensions. The Identify M tool will then interpolate the 3D length at any point along the line. Here is the Blog where you can download the Add In: geonet.esri.com/thread/102474 Jul 25, 2016 at 15:35