Description Usage Arguments Value Note Author(s) Examples
View source: R/normalize-grf-functions.R
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.
1 | normalize.grf.functions(grf.object, scaling.method = "uniform")
|
grf.object |
A GRF object generated by |
scaling.method |
Specifices whether the functions should be rescaled between 0 and 1 by a min-max scaling ( |
A normalized GRF object.
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.
Mathias Isaksen mathiasleanderi@gmail.com
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()
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.