% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/plot.R
\name{plot_spatial_pu}
\alias{plot_spatial_pu}
\title{Plot selected planning units in space}
\usage{
plot_spatial_pu(
  x,
  runs = NULL,
  ...,
  base_alpha = 0.1,
  selected_alpha = 0.9,
  base_fill = "grey92",
  base_color = NA,
  selected_color = NA,
  draw_borders = FALSE,
  show_base = TRUE
)
}
\arguments{
\item{x}{A \code{Solution} or \code{SolutionSet} object.}

\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{...}{Reserved for future extensions.}

\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
selected planning-unit 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 selected planning units.}

\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 selected units.}
}
\value{
Invisibly returns a \code{ggplot} object.
}
\description{
Plot the spatial distribution of selected planning units from a
\code{Solution} or \code{SolutionSet}.

This function maps the planning-unit selection summary returned by
\code{\link{get_pu}} onto the planning-unit geometry stored in the associated
\code{Problem} object.
}
\details{
Let \eqn{w_i \in \{0,1\}} denote the planning-unit selection variable for
planning unit \eqn{i}. This function plots the user-facing
\code{selected == 1} representation of \eqn{w_i}.

If several runs are requested, the output is faceted by \code{run_id}.

Planning-unit geometry must be available in \code{x$problem$data$pu_sf}.
}
\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_pu(sol)
}

}
\seealso{
\code{\link{get_pu}},
\code{\link{plot_spatial}},
\code{\link{plot_spatial_actions}},
\code{\link{plot_spatial_features}}
}
