Home > custom > grid_stats > slope_horn_deg.m

slope_horn_deg

PURPOSE ^

PURPOSE: calculate slope in degrees according to Horn for a DEM

SYNOPSIS ^

function [slope] = slope_horn_deg(x,y,z)

DESCRIPTION ^

 PURPOSE:  calculate slope in degrees according to Horn for a DEM
 -------------------------------------------------------------------
 USAGE: [slope] = slope_horn_deg(x,y,z)
 where: 
        [x] is a coordinate vector for the x axis
        [y] is a coordinate vector for the y axis
        [z] is a matrix holding the DEM values of size length(x)*length(y)
            matrix
 -------------------------------------------------------------------------
 OUTPUTS:
        [slope] is the slope calculated according to Horn using the 
                8 nearest neighbours of the center cell in degrees
       
 -------------------------------------------------------------------

 SEE ALSO: slope_horn, slaspect

 Felix Hebeler, Geography Dept., University Zurich, March 2006.
 Modified function, original by Felix Morsdorf, RSL, Uni ZH

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SUBFUNCTIONS ^

SOURCE CODE ^

0001 function [slope] = slope_horn_deg(x,y,z)
0002 % PURPOSE:  calculate slope in degrees according to Horn for a DEM
0003 % -------------------------------------------------------------------
0004 % USAGE: [slope] = slope_horn_deg(x,y,z)
0005 % where:
0006 %        [x] is a coordinate vector for the x axis
0007 %        [y] is a coordinate vector for the y axis
0008 %        [z] is a matrix holding the DEM values of size length(x)*length(y)
0009 %            matrix
0010 % -------------------------------------------------------------------------
0011 % OUTPUTS:
0012 %        [slope] is the slope calculated according to Horn using the
0013 %                8 nearest neighbours of the center cell in degrees
0014 %
0015 % -------------------------------------------------------------------
0016 %
0017 % SEE ALSO: slope_horn, slaspect
0018 %
0019 % Felix Hebeler, Geography Dept., University Zurich, March 2006.
0020 % Modified function, original by Felix Morsdorf, RSL, Uni ZH
0021 
0022   
0023 d = median(diff(x));  
0024 slope = atand(nlfilter(z,[3 3],@slopehorn)/d);
0025 
0026 
0027 
0028 %-------------------------------------------------------------------------------
0029 function [hslo] = slopehorn(z);   % Horns method
0030   dzdx = [z(1,3)+2*z(2,3)+z(3,3)-z(1,1)-2*z(2,1)-z(3,1)]/8;
0031   dzdy = [z(3,1)+2*z(3,2)+z(3,3)-z(1,1)-2*z(1,2)-z(1,3)]/8;
0032   hslo = sqrt(dzdx^2+dzdy^2);

Generated on Tue 24-Feb-2009 19:14:50 by m2html © 2003