I am doing some terrain analyses and I need to find distance from certain points to mountain ridges. I have used geodata
to access SRTM data, so I have a DEM. terra
has great built-in methods for calculating slope and TRI.
aspect <- terra::terrain(dem, v = "aspect")
tri <- terra::terrain(dem, v = "TRI")
slope <- terra::terrain(dem, v = "slope")
But, I have found no method for extracting ridges. I thought an approach would be to find the change in slope, but 1) here both peaks and valleys have 0 slope (i.e. there are no negative slopes), and 2) a focal
approach returns local maxima whereas I need to find the highest ridge.
Other answers on the stacks have focused on finding the highest point, but I need lines, not point values. In addition, I am using a wide geographic extent, so setting a threshold elevation for ridges is not viable.
Can anyone with more geography experience suggest a solution?
Thanks!