Purpose

The main purpose of Fourier analysis in this package is to rotate rasters so that they face the main components of the two-dimensional Fourier spectrum.

Loading data

First, we perform the basic steps from this vignette.

library("statisticalRoughness")
library("rayshader")
library("raster")

gabilan_mesa <- raster(file.path(system.file("extdata/rasters/", package = "statisticalRoughness"), "gabilan_mesa.tif"))
gabilan_mesa <- gabilan_mesa %>% detrend_dem() 
raster_resolution <- 9.015
FT2D <- fft2D(raster::as.matrix(gabilan_mesa), dx = raster_resolution, dy = raster_resolution, Hann = TRUE)
nbin <- 20
binned_power_spectrum <- bin(log10(FT2D$radial_frequency_vector), log10(FT2D$spectral_power_vector), nbin)
binned_power_spectrum <- na.omit(binned_power_spectrum)

Removing the background spectrum

Then we obtain a normalized spectral power matrix by removing the background spectrum. More details are provided in Perron, Kirchner, and Dietrich (2008).

normalized_spectral_power_matrix <- get_normalized_spectral_power_matrix(binned_power_spectrum, FT2D)

Filtering the spectral power matrix

This normalized spectral power matrix is then filtered to identify main components. While Perron, Kirchner, and Dietrich (2008) used a comparison with a \(\chi^2\) distribution, we keep the values spectral power that are above the 99.99th percentile of the logarithm of their values. The plot below corresponds, albeit not exactly, to their Fig. 3c.

filtered_spectral_power_matrix <- filter_spectral_power_matrix(normalized_spectral_power_matrix, FT2D, quantile_prob = c(0.9999))