Skip to content

Commit

Permalink
update to demprofile
Browse files Browse the repository at this point in the history
  • Loading branch information
wschwanghart committed Sep 2, 2020
1 parent d1b42c3 commit e7155a1
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 3 deletions.
31 changes: 28 additions & 3 deletions @GRIDobj/demprofile.m
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
% [d,z] = demprofile(DEM)
% [d,z] = demprofile(DEM,n)
% [d,z,x,y] = demprofile(DEM,n,x,y)
% p = demprofile(DEM,...)
% p = demprofile(DEM,p)
%
% Description
%
Expand All @@ -18,28 +20,40 @@
% DEM digital elevation model (class: GRIDobj)
% n number of points along profile
% x,y coordinate vectors of profile vertices
% p structure array (struct) returned by demprofile
%
% Output arguments
%
% d distance along profile
% z elevation values interpolated (linear) onto profile
% x,y coordinate vectors of profile
%
% p If only one output argument is used than demprofile returns
% a scalar structure array with fieldnames that refer to above
% listed output arguments.
%
% See also: GRIDobj/interp, GRIDobj/measure
%
% Author: Wolfgang Schwanghart (w.schwanghart[at]geo.uni-potsdam.de)
% Date: 17. August, 2017
% Date: 2. September, 2020


% interactive
if nargin <= 2;
if nargin <= 2

if nargin == 2 && isstruct(n)
x = n.x;
y = n.y;
dn = getdistance(x,y);
else

h = imagesc(DEM);
ax = get(h,'Parent');

[x, y] = getline(ax);
do = getdistance(x,y);

if nargin == 1;
if nargin == 1
n = ceil(do(end)/DEM.cellsize)*2;
end

Expand All @@ -49,6 +63,7 @@

x = xy(:,1);
y = xy(:,2);
end

else
if n ~= numel(x);
Expand All @@ -69,6 +84,16 @@

z = double(interp(DEM,x,y));

if nargout == 1

out.d = dn;
out.z = z;
out.x = x;
out.y = y;

dn = out;
end

end


Expand Down
1 change: 1 addition & 0 deletions readme.md
Original file line number Diff line number Diff line change
Expand Up @@ -126,6 +126,7 @@ resource for code and examples is the [TopoToolbox blog](https://topotoolbox.word
- new function: STREAMobj/STREAMobj2kml
- modification: STREAMobj/smooth
- new function: STREAMobj/mnoptimvar
- modification: GRIDobj/demprofile
- topoapp was removed from this version
- updates to utilities: setextent and getextent
- new function: padextent
Expand Down

0 comments on commit e7155a1

Please sign in to comment.