# How to calculate point(or XY) for Start point of Slope and Endpoint of Slope along the Section line on DTM

How to calculate point(or XY) for Start point of Slope and Endpoint of Slope along the Section line on DTM. for instance • This would be a challenge, because you need to define (mathematically) the characteristics of the points that you are looking for; And after that, find such points. Mar 17, 2015 at 8:42
• can you tell me what could be the pattern called marked above in snapshot. I mean what it could be called just like we say avarage, mean, median. etc etc Mar 17, 2015 at 8:53
• I'd call it an inflection point if looking at it just as a curve, but it could also be considered a percentile point (e.g. if you're thinking of the profile like a bell curve). Mar 17, 2015 at 12:34

From your diagram it appears that you're interested in the points where the change in gradient is the most. Since the gradient of a line measures the rate of change (i.e. can be considered the derivative), then the gradient of the gradient is the rate of change of the gradient (i.e. can be considered the second derivative). So from this assumption we can say local extrema of the gradient of the gradient are where the gradient changes the most, and thus are the points of maximum curvature of the line.

Using Python for a quick example of the calculation (I transcribed and uploaded the profile in the screenshot in your question to this gist for those interested).

``````import numpy as np
import matplotlib.pyplot as plt

``````

We can plot the gradient just for comparison (note the extrema of the gradient are the inflection points).

``````ax = plt.axes()
ax.axis('equal')
line1 = ax.plot(profile[:, 0], profile[:, 1], 'o-', label="Original profile")
ax.set_ylabel("Elevation", color="b")
for tl in ax.get_yticklabels():
tl.set_color("b")

ax2 = ax.twinx()
for tl in ax2.get_yticklabels():
tl.set_color("r")

lns = line1 + line2
labs = [l.get_label() for l in lns]
ax.legend(lns, labs, loc="best")
`````` Then look at the gradient of the gradient (the concavity), and use `scipy.signal` to determine local extrema.

``````import scipy.signal

local_maxima = scipy.signal.argrelmax(concavity)
local_minima = scipy.signal.argrelmin(concavity)

ax = plt.axes()
line1 = ax.plot(profile[:, 0], profile[:, 1], 'o-', label="Original profile")
ax.axis('equal')
ax.set_ylabel("Elevation", color="b")
for tl in ax.get_yticklabels():
tl.set_color("b")

ax2 = ax.twinx()

line2 = ax2.plot(profile[:, 0], concavity, 'r', label="Concavity")
for tl in ax2.get_yticklabels():
tl.set_color("r")
for i in local_minima:
line3 = ax2.axvline(profile[i, 0], color='r', ls=':', label="Local minima")
for i in local_maxima:
line4 = ax2.axvline(profile[i, 0], color='r', ls=':', label="Local maxima")

lns = line1 + line2 + [line3, line4]
labs = [l.get_label() for l in lns]
ax.legend(lns, labs, loc="upper right")
`````` Note you will get many local extrema depending on your slope profile, so it will likely be a case by case to determine which ones to consider as your solution.

• I love answers like these.
– Fezter
Mar 18, 2015 at 0:43
• @Fezter Cheers :) Mar 23, 2015 at 12:19