Ir al contenido

Creates a ggplot2 map of a single feature represented by a SpatRaster, with optional planning unit outlines, customizable color palette direction, and optional saving to disk.

Uso

elsar_plot_feature(
  raster_in,
  pus,
  legend_title = NULL,
  color_map = "viridis",
  invert_palette = FALSE,
  figure_path = NULL,
  iso3 = NULL,
  no_legend = FALSE,
  custom_resolution = 200
)

Argumentos

raster_in

SpatRaster. The raster to be plotted.

pus

SpatVector. Planning units used as an outline for the raster.

legend_title

character, optional. Title for the legend. Defaults to NULL.

color_map

character. Name of the viridis palette to use. Defaults to "viridis".

invert_palette

logical. If TRUE, reverses the palette direction. Defaults to FALSE.

figure_path

character, optional. If provided, path to save the figure as a PNG.

iso3

iso3 code of the country of interest.

no_legend

logical. If TRUE, suppresses the legend. Defaults to FALSE.

custom_resolution

A value that is used in ggsave() for dpi. Default is 200.

Valor

A ggplot object displaying the raster with optional planning unit outlines.

Ejemplos

if (FALSE) { # \dontrun{
boundary_proj <- make_boundary(
  boundary_in = boundary_dat,
  iso3 = "NPL",
  iso3_column = "iso3cd"
)

pus <- make_planning_units(
  boundary_proj = boundary_proj,
  iso3 = "NPL",
  pu_size = NULL,
  pu_threshold = 8.5e5,
  limit_to_mainland = FALSE
)

wad_dat <- get_wad_data()

wadOut <- make_normalised_raster(
  raster_in = wad_dat,
  pus = pus,
  iso3 = "NPL"
)

elsar_plot_feature(
  raster_in = wadOut,
  pus = pus,
  legend_title = "WAD",
  color_map = "magma",
  invert_palette = TRUE,
  figure_path = here::here(),
  no_legend = FALSE,
  iso3 = "test",
  custom_resolution = 400
)
} # }