function g = maxgradient(blockstruct) % calculate minimum and maximum and their locations zmax = max(blockstruct.data(:)); zmin = min(blockstruct.data(:)); % zero gradients, no further action required if zmax == zmin g = zeros(blockstruct.blockSize); return end IMAX = blockstruct.data == zmax; IMIN = blockstruct.data == zmin; D = bwdist(IMAX,'euclidean'); d = min(D(IMIN)); % calculate the gradient g = (zmax-zmin)/d; % replicate elements g = repmat(g,blockstruct.blockSize);

Cheers, Wolfgang

]]>That worked really nice. Thank you very much for making the things easier. However, there are still some pitfalls that I want to address. The maxgradient function needs to take care of the duplicate data. There might be more than one pixel which carries minimum or maximum value within a grid. Say for instance, if there is a flat plateau and/or a flat valley bottom within a single grid. It means that there might be multiple paths that connect max and min values (as there will be multiple values of max and min). So the minimum distance can be taken for the calculation of slope. Hope this will be taken care in the future.

This tool is a great contribution towards the field of quantitative geomorphology. Thank you for the constant effort.

Regards

Shantamoy ]]>

So how could this issue be solved. I’ll start with calculating the topographic range to show how to approach the problem.

DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif'); R = GRIDobj(DEM); R.Z = blockproc(DEM.Z,[50 50],@(x) repmat(max(x.data(:))-min(x.data(:)),x.blockSize)); imageschs(DEM,R)

The function blockproc is probably best to do calculations on individual blocks. Here, it tiles the DEM in equal blocks of 50 by 50 pixels. You need to change the vector [50 50] to do the calculation on different block sizes. In addition, blockproc takes an anonymous function that determines what to do with the block. Note, that x is a structure array that is described at the bottom of the function’s documentation. Here I simply calculate the difference between the maximum and the minimum, and then replicate the elements to obtain the original block size as output. So, basically, this is a one-liner.

For calculating the maximum gradient, we need to define another function that is a bit more bulky. Hence, we have to write a function that resides on MATLAB’s search path and that takes the a block structure as input. The function below is a first try and doesn’t solve for the issue of replicate maxima or minima.

function g = maxgradient(blockstruct) % calculate minimum and maximum and their locations [zmax,ixmax] = max(blockstruct.data(:)); [zmin,ixmin] = min(blockstruct.data(:)); % calculate row and column indices of maxima and minima [rmax,cmax] = ind2sub(blockstruct.blockSize,ixmax); [rmin,cmin] = ind2sub(blockstruct.blockSize,ixmin); % calculate the distance d = hypot(cmax-cmin,rmax-rmin); % calculate the gradient g = (zmax-zmin)/d; % replicate elements g = repmat(g,blockstruct.blockSize);

Now you can again call the function blockproc with following command.

R.Z = blockproc(DEM.Z,[50 50],@maxgradient);

Finally, this gives the gradient for a unit pixel spacing. Hence, calculate R as

R = R/R.cellsize;

And plot it:

imageschs(DEM,R)

Hope this does the trick.

Best regards, Wolfgang

]]>Many thanks for your reply and sorry for not being clear. Let me put it in this way.

Say, I have divided the DEM into several grids (let the size of the square grid is 5 km). This is not like traditional focal statistics, rather all the grids have to be discrete and will have no overlap. Now suppose we have divided the whole DEM into 100 grids. (So the size of DEM is 50 km by 50km). Therefore, we have 100 relief values from each grid.

The second part is the maximum slope. What I mean by maximum slope is one slope value from each grid. The relief is the difference between highest and lowest elevation value. Now if the locations of these highest and lowest points can be traced then the distance can be calculated. So

Max_slope = tan_inverse(Relief/Distance).

One problem will arise when there will be more than one max or min elevation value in one grid. But that can be solved by some other method. (Note that I have changed word gradient into slope)

Regards. ]]>

Cheers, Wolfgang ]]>

I was wondering that if we can get maximum gradient and corresponding relief values for the definite grids. It might be a slight variant of the EXCESSTOPOGRAPHY function. Is there any way to get these two variables with the existing functions in TopoToolbox?

Thank you in advance. ]]>

I have tried following code to be able to reproduce your findings:

DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif'); FD = FLOWobj(DEM); S = STREAMobj(FD,'minarea',1e6,'unit','map'); S = klargestconncomps(S); A = flowacc(FD); C = chiplot(S,DEM,A,'mn',0.45); plot(C.distance,C.pred) C = chiplot(S,DEM,A,'mn',2); figure plot(C.distance,C.pred)

I do not get the angular pattern that you describe, but the predicted elevations seem at odds with true elevations for a mn-ratio of 2. The mn-ratio usually ranges between 0.2 to 0.8 (often it is set to 0.45), so this is something that I’d expect as such a high mn-ratio is unable to linearize the relation between chi and elevation.

You are completely right with the robustness of chi analysis to errors in DEMs. This is something that Royden and Perron describe in their paper as a major motivation for developing this approach. Unless you are dealing with a lot of scatter, smoothing is usually not necessary for chi analysis. Whether results from chi analysis are vastly different depends on the noise in the slope area regression. Given the robustness of the chi approach, I’d always rely on mn ratios derived from chi analysis rather than those obtained from slope area plots.

Cheers, Wolfgang

While using chiplot to find the optimum m/n ratio for small streams, i found that the resulting structure C (created as C = chiplot(S,DEM,A);) has a predicted value as C.pred. When i plotted this value (C.distance vs C.pred) versus C.distance vs C.elevbl i found that C.pred has a a very angular shape (an obtuse angle) , especially when theta values are > 2, as opposed to the gentle logarithmic shape i expected. Is that expected? Please can you comment on that?

I was also thinking, given how noisy SRTM elevation data is (with its stair-step features), chiplot completely removes the need to compute spatial gradients. And because of that, there is no need to do spatial smoothing or resampling of the data at fixed contour lines. I think this is a very neat method ðŸ™‚ But i wonder if results of channel steepness and concavities of individual streams calculated using an integral method will be vastly different when compared to slope-area regression?

cheers,

RIshav

many thanks for your comment. I am particularly glad to hear that TopoToolbox and this blog has been helpful to you!

Concerning your question how large values of K in the crs function affect the slope-area regression, I think it would be best to do a sensitivity study. As you increase the value of K to very high values, your channel profile will basically become a straight line. Large values of K would penalize curvature much more than a misfit to the data. Too small values of K, conversely, might produce plateaus (similar to those produced by quantile carving) that might neither be a good representation of the profile. An optimal value would reflect the true profile while removing the bumps that generate the large scatter in slope-area plots. Traditionally, slope-area plots have dealt with scatter using binning. It would definitely be interesting to see whether we can avoid binning using smoothing.

In fact, your comment concerns an issue that has also been mentioned by reviewers of our discussion paper in ESURF and it gives me an idea how to address them (possibly also in a future blog post).

Cheers, WS ]]>

Thank you so much for all your inputs on this blog. I went from having no idea where to begin to doing quite a bit of fluvial geomorphology with TopoToolbox in a short span of time.

I wonder what effect using large values of K (say >1000 ) in the crs function has on slope-area regression. While, it does seem to correct the stair-like profile that a lot of SRTM DEMs have, i’m curious if it also changes the theta value obtained from regression? Can you provide some insight into this?

Thanks,

Rishav