English

# How To: Calculate the instantaneous slope of a linear feature across a surface

## Summary

The properties of an elevation surface can be used to determine the slope of a linear feature. The slope at each cell of a grid/lattice will be used to determine the slope of the line section that crosses that cell.

Note that this calculation is different than finding the slope of the surface along the feature.
� If the direction of a line section over a cell is the same as the direction of maximum slope, the slope of that section will be the same as the cell.
� If the line section direction is perpendicular to the slope direction, that section will have a calculated slope of 0.
� When the direction of the line segment is at some angle other than perpendicular or parallel to the cell's slope direction, it's slope will be a proportion of the cell's.

For example, the direction of maximum slope for a cell on the surface is 180 degrees (south), and the slope is 10 degrees. A line traverses this cell in the same direction (south). The slope of the component of the line crossing this cell in the same direction is also 10 degrees. However, were the line section headed perpendicular to the cell direction (90 degrees), the slope would be 0. If the line were traversing the cell in a diagonal say to the southeast (135 degrees), the slope would be about 7 degrees.

Mathematically, the slope of the line segment is taking the cosine of the angle between the direction of the surface and the direction of the line segment, and multiplying it by the slope of that cell.

## Procedure

The procedure described here will work only when the resolution of the surface is higher than that for the linear features. Having the linear feature change direction within a cells area will create spurious results. The relationship between the resolution of the linear features and the surface should be such that at least several surface cells are required to represent each straight-line section of the linear feature.

Generate line cover where each straight line section records the orientation.

a. Create coverage where the straight section of each arc becomes a new
arc itself.

`Code:&SV covername = <name_of_pipe_coverage>BUILD %covername% ARCS           ARCEDITDISPLAY 9999EDIT %covername% ARCSSEL ALL&SV totalarcs = [SHOW NUMBER SELECTED]&DO arccounter = 1 &TO %totalarcs%      SELECT \$RECNO = %arccounter%  SETDEF CURRENT  &IF [SHOW ARC %arccounter% NPNTS] GT 2 &THEN    &DO      &SV numbervertex = [CALC [SHOW ARC %arccounter% NPNTS]  - 2]      &DO vertexcounter = 2 &TO [CALC %numbervertex%  + 1]        &pushpoint 1,[SHOW ARC [SHOW SELECT 1] VERTEX %vertexcounter%]        &pushpoint 1,[SHOW ARC [SHOW SELECT 1] VERTEX %vertexcounter%]      &END      &DO splitcounter = 1 &TO %numbervertex%        SELECT        SPLIT      &END    &END  SETDEF NONE&ENDSAVE YESQUIT`

b. Add the orientation to each arc.
`Code:&SV covername = <name_of_pipe_coverage>&DESCRIBE %covername%&SV totalarcs = %DSC\$ARCS%ARCEDITDISPLAY 9999EDIT %covername% ARCSEF ARCADDITEM angle 4 5 B&DO arccounter = 1 &TO %totalarcs%   SELECT %covername%#  = %arccounter%       &SV vert = [SHOW ARC %arccounter% VERTEX 1]   &SV orient = [SHOW ARC %arccounter% ORIENTATION %vert%]   CALC angle = %orient%&ENDSAVE YESQUIT`

Convert the line cover to a grid based on the angle item.

`Code:pipegrd = LINEGRID (pipecov, angle)`

Correct the angle measurement (Orientation and Grid measure angles differently)

`Code:pipeangle = ( 450 - pipegrd ) MOD 360  Alternatively:pipeangle = CON ( orien GE 0 AND orien LE 90, 90 - orien, ~                  CON ( orien GT 90, 360 - (orien - 90) )  )`

Generate the slope grid.

`Code:elslope = SLOPE (elev)`

Generate the aspect grid.

`Code:elaspect = ASPECT (elev)`

Calculate slope along direction of pipeline.

`Code:slopepipe = elslope * COS ( (pipeangle - elaspect) DIV deg)`

Calculate slope perpendicular to pipleline, in downslope direction.

`Code:slopeperp = CON ( ABS( (360 - (pipeangle + 90) ) - elaspect) ~   GE ABS( (360 - (pipeangle - 90))-elaspect ), ~  elslope * COS ( ( pipeangle - elaspect - 90) DIV deg) ~    elslope * COS ( ( pipeangle - elaspect + 90) DIV deg) )`

For a download that calculates the slope of each line in a line theme based on underlying TIN or grid theme, see the link in Related Information below.