% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.R
\name{plot_spatial}
\alias{plot_spatial}
\title{Plot spatial outputs from a solution or solution set}
\usage{
plot_spatial(
  x,
  what = c("pu", "actions", "features"),
  runs = NULL,
  actions = NULL,
  features = NULL,
  value = c("final", "baseline", "benefit"),
  layout = NULL,
  max_facets = 4L,
  ...,
  base_alpha = 0.1,
  selected_alpha = 0.9,
  base_fill = "grey92",
  base_color = NA,
  selected_color = NA,
  draw_borders = FALSE,
  show_base = TRUE,
  fill_values = NULL,
  fill_na = "grey80",
  use_viridis = TRUE
)
}
\arguments{
\item{x}{A \code{Solution} or \code{SolutionSet} object.}

\item{what}{Character string indicating what to plot. Must be one of
\code{"pu"}, \code{"actions"}, or \code{"features"}.}

\item{runs}{Optional integer vector of run ids. If \code{NULL}, a
\code{Solution} is used directly and a \code{SolutionSet} defaults to the
first run.}

\item{actions}{Optional action subset used when \code{what = "actions"}.}

\item{features}{Optional feature subset used when \code{what = "features"}.}

\item{value}{Character string used only when \code{what = "features"}.
Must be one of \code{"final"}, \code{"baseline"}, or \code{"benefit"}.}

\item{layout}{Character string controlling the layout. Must be one of
\code{"single"} or \code{"facet"}. If \code{NULL}, the default is
\code{"single"} for planning units and actions, and \code{"facet"} for
features.}

\item{max_facets}{Maximum number of facets shown when faceting without an
explicit action or feature subset.}

\item{...}{Additional arguments passed to the specialised plotting function.}

\item{base_alpha}{Numeric value in \eqn{[0,1]} giving the alpha of the base
planning-unit layer.}

\item{selected_alpha}{Numeric value in \eqn{[0,1]} giving the alpha of the
highlighted layer.}

\item{base_fill}{Fill colour for the base planning-unit layer.}

\item{base_color}{Border colour for the base planning-unit layer.}

\item{selected_color}{Border colour for highlighted layers.}

\item{draw_borders}{Logical. If \code{FALSE}, borders are not drawn.}

\item{show_base}{Logical. If \code{TRUE}, draw the base planning-unit layer
underneath the highlighted output.}

\item{fill_values}{Optional named vector of colours for discrete maps.}

\item{fill_na}{Fill colour for missing values.}

\item{use_viridis}{Logical. If \code{TRUE} and the \pkg{viridis} package is
available, use viridis scales.}
}
\value{
Invisibly returns a \code{ggplot} object.
}
\description{
Convenience wrapper to plot spatial outputs from a \code{Solution} or
\code{SolutionSet}.

Depending on \code{what}, this function dispatches to one of:
\itemize{
\item \code{\link{plot_spatial_pu}},
\item \code{\link{plot_spatial_actions}},
\item \code{\link{plot_spatial_features}}.
}

This wrapper is useful as a compact entry point, while the specialised
plotting functions provide a cleaner and more explicit user interface for
each spatial output type.
}
\examples{
if (requireNamespace("sf", quietly = TRUE) &&
    requireNamespace("ggplot2", quietly = TRUE)) {
  data("sim_pu_sf", package = "multiscape")

  problem <- structure(
    list(
      data = list(
        pu_sf = sim_pu_sf
      )
    ),
    class = "Problem"
  )

  sol <- structure(
    list(
      problem = problem,
      summary = list(
        pu = data.frame(
          id = sim_pu_sf$id,
          selected = as.integer(seq_len(nrow(sim_pu_sf)) \%\% 2 == 1)
        )
      )
    ),
    class = "Solution"
  )

  plot_spatial(sol, what = "pu")
}

}
\seealso{
\code{\link{plot_spatial_pu}},
\code{\link{plot_spatial_actions}},
\code{\link{plot_spatial_features}}
}
