Skip to content

Commit

Permalink
added prominence
Browse files Browse the repository at this point in the history
  • Loading branch information
wschwanghart committed Jun 28, 2021
1 parent 86eb129 commit be870e4
Show file tree
Hide file tree
Showing 3 changed files with 85 additions and 4 deletions.
79 changes: 79 additions & 0 deletions @GRIDobj/prominence.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
function [x,y,p] = prominence(DEM,tol)

%PROMINENCE Calculate the prominence of mountain peaks
%
% Syntax
%
% [x,y,p] = prominence(DEM,tol)
%
% Description
%
% This function calculates the prominence of peaks in a DEM. The
% prominence is the minimal amount one would need to descend from a
% peak before being able to ascend to a higher peak.
%
% The function uses image reconstruct (see function imreconstruct) to
% calculate the prominence. It may take a while to run for large DEMs.
% The algorithm iteratively finds the next higher prominence and stops
% if the prominence is less than the tolerance, the second input
% parameter to the function.
%
% The function opens a waitbar which let's you quit the operation. The
% list of coordinates and prominence values derived until then, are
% returned as output arguments.
%
% Input arguments
%
% DEM Digital elevation model (GRIDobj)
% tol tolerance in [m] with the minimum prominence.
%
% Output arguments
%
% x,y coordinate values of peaks
% p prominence (the first element in the vector contains the
% highest peak for which prominence (given above definition)
% cannot be calulated.
%
% See also: GRIDobj
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 28. June, 2021

if any(isnan(DEM))
DEM.Z(isnan(DEM.Z)) = 0;
end

P = GRIDobj(DEM)+min(DEM);
P2 = P;
C = P;

counter = 1;
p = inf;

f = waitbar(0,'1','Name','Calculating prominence...',...
'CreateCancelBtn','setappdata(gcbf,''canceling'',1)');

setappdata(f,'canceling',0);


while p(end) > tol

[p(counter),ix(counter)] = max(DEM-P);

waitbar(min(max(tol/p(end),0),1),f,sprintf('%5.2f',p(end)))

P.Z(ix) = DEM.Z(ix);
P.Z = imreconstruct(P.Z,DEM.Z);
counter = counter + 1;

% Check for clicked Cancel button
if getappdata(f,'canceling')
break
end

end

delete(f);
[x,y] = ind2coord(DEM,ix);
p = p(:);

8 changes: 5 additions & 3 deletions colormaps/ttscm.m
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,12 @@
%
% DEM = GRIDobj('srtm_bigtujunga30m_utm11.tif');
% cmaps = ttscm;
% tiledlayout('flow','TileSpacing','none');
% for r = 1:numel(cmaps);
% subplot(6,4,r);
% nexttile
% imageschs(DEM,[],'colormap', ttscm(cmaps{r}),...
% 'colorbar',false,'ticklabels','none');
% 'colorbar',false,'ticklabels','none',...
% 'useperm',true);
% title(cmaps{r});
% end
%
Expand Down Expand Up @@ -100,7 +102,7 @@
'InitialMagnification','fit')
return
elseif nargin == 0 && nargout == 1
cmap = allowedcmaps;
cmap = sort(allowedcmaps);
return
end

Expand Down
2 changes: 1 addition & 1 deletion readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -117,7 +117,7 @@ resource for code and examples is the [TopoToolbox blog](http:https://topotoolbox.word
- new class: DIVIDEobj [Paper 1 DOI: 10.5194/esurf-8-245-2020](https://doi.org/10.5194/esurf-8-245-2020)
[Paper 2 DOI: 10.5194/esurf-8-261-2020](https://doi.org/10.5194/esurf-8-261-2020)
- new class: PPS [DOI: 10.1002/esp.5127](http:https://dx.doi.org/10.1002/esp.5127)
- modification: update to ttscm to include cyclic colormaps;
- modification: update to ttscm to Scientific Colormaps 7.0
see [Fabio Crameri's website](http:https://www.fabiocrameri.ch/colourmaps.php)
- new function: GRIDobj/diffusion
- new function: GRIDobj/histogram
Expand Down

0 comments on commit be870e4

Please sign in to comment.