normalize.grf.functions: Normalize GRF functions

Description Usage Arguments Value Note Author(s) Examples

View source: R/normalize-grf-functions.R

Description

This function ensures that each function in the specified GRF object is between 0 and 1 in value, and that the functions sum to 1 at every location. This is useful when the functions are used to compute a weighted mean of multiple layers.

Usage

1
normalize.grf.functions(grf.object, scaling.method = "uniform")

Arguments

grf.object

A GRF object generated by generate.grf.object.

scaling.method

Specifices whether the functions should be rescaled between 0 and 1 by a min-max scaling (scaling.method = "minmax"), or a uniform scaling (scaling.method = "uniform").

Value

A normalized GRF object.

Note

The properties above (summing to 1 and between 0 and 1 in value) only hold in the grid locations. When interpolating in arbitrary locations, small deviations will occur.

Author(s)

Mathias Isaksen mathiasleanderi@gmail.com

Examples

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
library(GRFics)
library(ggplot2)
grf.object = generate.grf.object(-1, 1, -1, 1, 100, 100,
                                 num.functions = 2)
grf.object = normalize.grf.functions(grf.object)


function.1.df = get.function.df(grf.object, function.numbers = 1)
function.2.df = get.function.df(grf.object, function.numbers = 2)
sum.df = data.frame(x = function.1.df$x,
                    y = function.1.df$y,
                    z = function.1.df$z + function.2.df$z,
                    name = "Sum")
comparison.df = rbind(function.1.df, function.2.df, sum.df)
ggplot()+
  geom_raster(data = comparison.df, aes(x = x, y = y, fill = z))+
  facet_wrap(vars(name))+
  coord_fixed()

mathiasisaksen/GRFics documentation built on May 20, 2021, 5:55 a.m.