Skip to content

Commit

Permalink
some modifications and updates
Browse files Browse the repository at this point in the history
- change of imagesc to show nans as fully transparent
- new function istrunk
  • Loading branch information
wschwanghart committed Feb 21, 2022
1 parent bf1c7d4 commit ba4ee7f
Show file tree
Hide file tree
Showing 3 changed files with 50 additions and 6 deletions.
26 changes: 20 additions & 6 deletions @GRIDobj/imagesc.m
Original file line number Diff line number Diff line change
Expand Up @@ -4,28 +4,42 @@
%
% Syntax
%
% h = imagesc(DEM,varargin)
% h = imagesc(DEM)
% h = imagesc(DEM,'nanstransparent',true)
%
% Description
%
% see imagesc
% This function overloads the built-in imagesc. In contrast to imagesc,
% however, the function sets nans in the DEM to transparent. For
% further information see the documentation of imagesc.
%
%
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 18. February, 2022

%% Update on 18. Feb 2022
% nans in the data are set to transparent

[x,y] = refmat2XY(DEM.refmat,DEM.size);
ht = imagesc(x,y,DEM.Z,varargin{:});
p = inputParser;
p.KeepUnmatched = true;
addParameter(p,'nanstransparent',true, @(x) isscalar(x));
parse(p,varargin{:})

[x,y] = refmat2XY(DEM.refmat,DEM.size);
ht = imagesc(x,y,DEM.Z,p.Unmatched);

axis xy
axis image

ht.AlphaData = ~isnan(DEM.Z);
if p.Results.nanstransparent
if isscalar(ht.AlphaData)
ht.AlphaData = ~isnan(DEM.Z);
else
ht.AlphaData = ht.AlphaData .* (~isnan(DEM.Z));
end
end

if nargout == 1;
if nargout == 1
h = ht;
end
29 changes: 29 additions & 0 deletions @STREAMobj/istrunk.m
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
function tf = istrunk(S)

%ISTRUNK Determines whether STREAMobj consists of trunk streams
%
% Syntax
%
% tf = istrunk(S)
%
% Description
%
% istrunk determines whether a STREAMobj S consists of one or several
% trunk streams. This is the case if there are as many outlet points as
% there are channelheads.
%
% Input arguments
%
% S STREAMobj
%
% Output arguments
%
% tf true or false
%
% See also: STREAMobj/streampoi
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 21. February, 2022

tf = numel(streampoi(S,'channelhead','ix')) == ...
numel(streampoi(S,'outlets','ix'));
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,7 @@ resource for code and examples is the [TopoToolbox blog](https://topotoolbox.word
- modification: STREAMobj/smooth
- new function: STREAMobj/mnoptimvar
- modification: STREAMobj/STREAMobj2cell
- modification: STREAMobj/istrunk
- modification: GRIDobj/demprofile
- new function: ScaleBar
- new function: xlinerel and ylinerel
Expand Down

0 comments on commit ba4ee7f

Please sign in to comment.