Description Usage Arguments Details Value Examples
View source: R/LandCoverPlot.R
This function is meant to create various plots associted with the landcover data, both before and after the simulation of the spread. Note that plots related specifically to the timelapse itself (yearly landcover, line graphs) are better plotted with the SimulationPlots
function.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 | LandCoverPlot(
raster,
value_type = "continuous",
blank_background = TRUE,
legend_title = element_blank(),
font_size = 15,
break_at_zero = FALSE,
priority_categories = 5,
priority_outlier_value = NA,
decimal_points = 0,
flip_colors = FALSE,
RColorBrewer_type = "qual",
RColorBrewer_palette = "Dark2",
continuous_type = "viridis",
continuous_break0_low = "#440154FF",
continuous_break0_high = "#FDE725FF",
continuous_break0_mid = "lightgray",
priority_plot_scalebar_position = "bottomright",
priority_plot_scalebar_unit = "km",
priority_plot_scalebar_dist = 1,
categorical_direction = 1
)
|
raster |
a |
value_type |
character string. Specifies whether the values you are plotting are |
blank_background |
logical. Do you want to remove the plot background (i.e. grid lines, tick marks, legend titles, etc.)? Default is |
legend_title |
character string. The legend title. Default is blank. |
font_size |
numerical. Font size of text in the plot. Default is 11. |
break_at_zero |
logical. Should categories be split at 0? Works for continuous and priority plots. Default is |
priority_categories |
numerical. If |
priority_outlier_value |
numerical. A value specifying an additional priority category for outliers. Can be either positive or negative. |
decimal_points |
numerical. Specifies the number of decimal points to report in the legend. Default is 0. |
flip_colors |
logical. Should the priority colors be flipped? Default is |
RColorBrewer_type |
character string. For |
RColorBrewer_palette |
character string. For |
continuous_type |
character string. For |
continuous_break0_low |
character string. For |
continuous_break0_high |
character string. For |
continuous_break0_mid |
character string. For |
categorical_direction |
numerical. For |
... |
Pass additional arguments to adjust the legend and coloring (breaks, labels, limits, color/fill, etc.) |
See ?ggplot and ?scale_fill_continuous and ?scale_fill_manual for details about plotting with ggplot and adjusting the legend and colors
A a ggplot
object
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | set.seed(1)
library(LandCover); library(gridExtra); library(ggplot2); library(raster); library(foreach); library(rasterVis)
# initialize data.frame with coordinates
dat <- expand.grid(x = 1:20, y = 1:20, KEEP.OUT.ATTRS = FALSE)
# create some data: elevation, landcover, and temp/ET dependent on elevation and landcover
dat$elevation <- with(dat, 50 + 2*x + 5*y + rnorm(nrow(dat), sd = 7))
dat$landcover <- ifelse(dat$elevation < median(dat$elevation), 1, 2)
dat[dat$x < median(dat$x) & dat$landcover == 2, 'landcover'] <- 3
dat$temp <- with(dat, (120-0.7*(0.5*elevation + 0.3*y - 0.5*x + ifelse(landcover == 'lc1', -30, 0) + rnorm(nrow(dat)))))
dat$ET <- with(dat, ( -0.4*(-2*temp + 0.5*y - 1.0*x + ifelse(landcover == 'lc1', +20, 0) + rnorm(nrow(dat)))))
# run regression
regression_results <- gls_spatial(data = dat, landcover_varname = 'landcover', landcover_vec = c(1,2), reg_formula = ET ~ elevation + temp, error_formula = ~x+y)
# get predicted values data
predicted_values <- gls_spatial_predict(data = dat, regression_results = regression_results, landcover_varname = 'landcover', landcover_invasive = 1, landcover_susceptible = 2, dep_varname = 'ET',
x_coords_varname = 'x', y_coords_varname = 'y')
LandCoverPlot(ET_predicted_lc1_raster)
|
Add the following code to your website.
For more information on customizing the embed code, read Embedding Snippets.