2

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

enter image description here

3
  • 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
  • 2
    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).
    – Erica
    Mar 17, 2015 at 12:34

1 Answer 1

5

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

gradient = np.gradient(profile[:, 1])

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()
line2 = ax2.plot(profile[:, 0], gradient, "r", label="Gradient")
ax2.set_ylabel("Gradient", color="r")
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")

Plot of gradient vs original profile

Then look at the gradient of the gradient (the concavity), and use scipy.signal to determine local extrema.

import scipy.signal

concavity = np.gradient(gradient)
local_maxima = scipy.signal.argrelmax(concavity)[0]
local_minima = scipy.signal.argrelmin(concavity)[0]

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")
ax2.set_ylabel("Gradient of gradient", color="r")
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")

Local minima and maxima of concavity

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.

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.