rspectrum: r-spectrum

Description Usage Arguments Details Value See Also Examples

View source: R/RcppExports.R

Description

Compute the r-spectrum of a matrix

Usage

1
rspectrum(mat)

Arguments

mat

A matrix with logical or numeric values

Details

This functions returns a data.frame with NAs in the rspec column if the input matrix has zero variance. Note that if the matrix is not square, then only the largest square matrix fitting in the upper right corner is used.

Value

A data.frame with two columns: dist, the wave number and rspec, the normalized value of the r-spectrum

See Also

spectral_spews, indicator_sdr

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
# Spectrum of white noise
rmat <- matrix(runif(100*100) > .5, ncol = 100)
spec <- rspectrum(rmat) 
plot(spec, type = "l")

# Add some spatial correlation and compare the two spectra
rmat.cor <- rmat
for (i in seq(1, nrow(rmat)-1)) { 
  for (j in seq(1, nrow(rmat)-1)) { 
    rmat.cor[i,j] <- mean(rmat[(i-1):(i+1), (j-1):(j+1)])
  }
}
spec.cor <- rspectrum(rmat.cor)
plot(spec.cor, type = "n")
lines(spec, col = "black")
lines(spec.cor, col = "blue")

spatialwarnings documentation built on May 2, 2019, 5:16 p.m.