====== folded_aspect ======
**Author: David Zelený**
The function uses aspect (in degrees) and returns folded aspect, i.e. the value of the aspect "folded" along selected axis (e.g. NE--SW). The formula for folded aspect (modified from [[en:references|McCune & Keon 2002]]) is:
aspect_folded~=~delim{|}{180-delim{|}{aspect-(180+alpha)}{|}}{|}
\\
where //aspect// is the measured value of aspect, and alpha is the aspect for which the folded aspects should be zero (for folding along NE-SW axis, alpha = 45°). The formula works only for values of alpha in the range 0-180°.
folded_aspect <- function (aspect, alpha = 45)
{
if (alpha > 180) stop ('Alpha must be in range between 0 and 180 degrees!')
fa <- abs (180 - abs (aspect - (180+alpha)))
return (fa)
}
Example of the use on the dataset ''grasslands.env'' (acidophilous grasslands in Třebíč region, Czech Republic). The ''grasslands.env'' contains variables ''aspect'', ''slope'' and ''latitude'', all in degrees. Dataset represents small plots (16-25m2) located on convex outcrops in the agricultural landscape, covered by seminatural grassland vegetation.
source ('http://anadat-r.davidzeleny.net/doku.php/en:customized_functions:folded_aspect?do=export_code&codeblock=0') # reads the function definition from above
grasslands.env <- read.delim ('https://raw.githubusercontent.com/zdealveindy/anadat-r/master/data/grasslands-env.txt') # loads the file
# Calculat folded aspect from grasslands.env$aspect:
f.aspect <- folded_aspect (aspect = grasslands.env$aspect, alpha = 45)
plot (f.aspect ~ grasslands.env$aspect) # plots values of folded aspect against the original aspect
{{:obrazky:folded_aspect_trebic_grasslands.png?direct|}}