Home > custom > grid_stats > fastder.m

fastder

PURPOSE ^

calculate slope and aspect (deg) using GRADIENT function

SYNOPSIS ^

function [grad,asp] = fastder(dem,X,Y)

DESCRIPTION ^

 calculate slope and aspect (deg) using GRADIENT function
 USAGE: [grad,asp] = fastder(dem,X,Y)
 Note: 0 and 360deg are North direction (Matlab std is East!)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [grad,asp] = fastder(dem,X,Y)
0002 % calculate slope and aspect (deg) using GRADIENT function
0003 % USAGE: [grad,asp] = fastder(dem,X,Y)
0004 % Note: 0 and 360deg are North direction (Matlab std is East!)
0005 
0006 dx=abs(X(2)-X(1));  % get cell spacing in x and y direction
0007 dy=abs(Y(2)-Y(1));  % from coordinate vectors
0008 [fx,fy] = gradient(dem,dx,dy); % uses simple, unweighted gradient of immediate neighbours
0009 [asp,grad]=cart2pol(fy,fx); % convert to carthesian coordinates
0010 grad=atand(grad); %steepest slope
0011 asp = asp*180/pi;
0012 asp(asp<0) = asp(asp<0) + 360;
0013 asp = 360 - asp;
0014 %asp = 270 - asp;
0015 %asp(asp<0) = asp(asp<0) + 360;

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