fitplane: Calculate a Least Squares Polynomial Surface

View source: R/utilities.R

fitplaneR Documentation

Calculate a Least Squares Polynomial Surface

Description

Fits a polynomial surface of order n to a raster or matrix.

Usage

fitplane(x, order)

Arguments

x

A raster or matrix.

order

Numeric. Indicates the polynomial order to be fit.

Value

A matrix with values predicted from the polynomial fit.

Examples


# import raster image
data(orforest)
orforest <- terra::unwrap(orforest)

# find the 2nd order least squares polynomial surface
polyfit <- fitplane(orforest, order = 2)

# create raster of polyfit
x <- terra::setValues(orforest, polyfit)

# plot the fit
terra::plot(x)

geodiv documentation built on Oct. 6, 2023, 1:07 a.m.