I have a 3D stream centerline shapefile that and I am trying to flag inflection points along the profile using ArcGIS Pro with Python 3, specifically where elevation changes by 0.5 feet or more. Here are some examples of the inflection points I am talking about:
I have a table with the vertices and elevation for each one. I added a field called 'Flag' to store which vertices are the inflection points.
How can I flag points where the elevation rises or drops by 0.5 feet?
I'm not sure how your data is currently represented in your program. If you can convert it to a numpy array, diff()
calculates the discrete difference between elements
Converting to numpy arrays if you have the values in a list is as easy as
my_numpy_array = np.array(my_list)
Let's say you have the y-axis values in an array y
and the x-axis values in an array x
.
We can find f'(x)
by
f1 = diff(y)/diff(x)
and f''(x)
by
f2 = diff(f1) / diff(x)
Pad the length of these arrays with nan
so that they're the same length as x
.
f1_p = np.pad(f1, (0, x.shape[0]), mode='constant', constant_values=(np.nan))
f2_p = np.pad(f2, (0, x.shape[0]), mode='constant', constant_values=(np.nan))
Then you can use numpy's logical_and
to check for f2_p == 0
and f1_p > 0.5
flag = np.logical_and(f2_p == 0, f1_p > 0.5)