# Calculating slope of a linear feature across a surface

Question asked by klemen74 on Feb 3, 2020

Dear Sirs,

My name is Klemen. I work a lot with road networks in 3D GIS.

I would like to calculate an accurate slope for road network lines. I use the tool "Add Surface Information" (ArcGIS for Desktop).

As a result, in the areas of steeper slope, the slope value of road segment differs so much from the slope of underlying raster.

There is an example in the attached figure. We can see an area of 9 cells. The size of one cell is 5 x 5 meters. Red numbers represent the values of elevations (in meters) for each cell. Blue numbers represent the values of slope for each cell (in degrees). The green line is one road segment. It's length in 2D GIS is only 9,189 meters. The green segment crosses four cells. After using the tool "Add Surface Information", the result for 3D length is 10,99 meters and for average slope is 65,61 degrees. How can the value of average slope of road segment differ so much from the slope of raster cells (blue valus)??

I'm thinking that the solution of my problem could be the use of code in following support: How To: Calculate the instantaneous slope of a linear feature across a surface  . I would like to use that code in ArcPy, but my colleagues told me, that the existing code is not written in ArcPy (my personal knowledge of Python is not good). Do you know this code in Python (ArcPy)? I would really like to try it.

Thank you very much!

Klemen