LandCoverPlot: Create various plots associated with the landcover data.

Description Usage Arguments Details Value Examples

View source: R/LandCoverPlot.R

Description

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.

Usage

 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
)

Arguments

raster

a raster object. The raster you wish to plot

value_type

character string. Specifies whether the values you are plotting are 'continuous', 'categorical', or 'priority'. Default is 'continuous'. See details.

blank_background

logical. Do you want to remove the plot background (i.e. grid lines, tick marks, legend titles, etc.)? Default is TRUE

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 FALSE.

priority_categories

numerical. If value_type = 'priority', specifies the number of non-zero priority categories to plot. Default is 5. If priority_colors are not specified, max value is 9.

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 FALSE. Useful for negative values.

RColorBrewer_type

character string. For value_type = 'categorical', specify the RColorBrewer type. See ?RColorBrewer. Default is 'qual'

RColorBrewer_palette

character string. For value_type = 'categorical', specify the RColorBrewer palette. See ?RColorBrewer. Default is 'Dark2'

continuous_type

character string. For value_type = 'continuous', specify color scale. See ?scale_fill_continuous. Default is colorblind-friendly viridis.

continuous_break0_low

character string. For value_type = 'continuous' and break_at_zero = TRUE, set the low color. See ?scale_color_gradient2.

continuous_break0_high

character string. For value_type = 'continuous' and break_at_zero = TRUE, set the high color. See ?scale_color_gradient2.

continuous_break0_mid

character string. For value_type = 'continuous' and break_at_zero = TRUE, set the color for values of 0. See ?scale_color_gradient2.

categorical_direction

numerical. For value_type = 'categorical', flip the direction of the color scale by setting the value to -1.

...

Pass additional arguments to adjust the legend and coloring (breaks, labels, limits, color/fill, etc.)

Details

See ?ggplot and ?scale_fill_continuous and ?scale_fill_manual for details about plotting with ggplot and adjusting the legend and colors

Value

A a ggplot object

Examples

 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)

natedemaagd/LandCover documentation built on April 1, 2021, 4:14 p.m.