% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/pep_outliers_leaflet.R
\name{pep_outliers_leaflet}
\alias{pep_outliers_leaflet}
\title{Interactive Leaflet Map of Outlier-Flagged Stations}
\usage{
pep_outliers_leaflet(
  x,
  outlier_only = TRUE,
  top_n = 10,
  radius_range = c(4, 14),
  palette = "plasma",
  ...
)
}
\arguments{
\item{x}{A \code{pep_outliers} object from \code{\link{pep_flag_outliers}}.
Must contain \code{lon}, \code{lat}, \code{s_id}, \code{year},
\code{phase_id}, \code{day}, \code{is_outlier}, and \code{deviation}
columns.}

\item{outlier_only}{Logical. If \code{TRUE} (default), only stations
with at least one flagged observation are shown. If \code{FALSE},
every station appears (non-flagged stations are drawn small and
grey for context).}

\item{top_n}{Integer. Maximum number of station-year records included
in a station's popup. Default 10.}

\item{radius_range}{Numeric length-2. Minimum and maximum circle
marker radius (in pixels) mapped to log1p(n_outliers). Default
\code{c(4, 14)}.}

\item{palette}{Character. Name of a \code{RColorBrewer} or viridis
palette for the colour scale. Default \code{"plasma"}.}

\item{...}{Additional arguments reserved for future expansion.}
}
\value{
A \code{leaflet} htmlwidget. Call \code{print()} to display
in the RStudio Viewer or embed it in an Rmd file.
}
\description{
Renders a Leaflet map of the stations in a \code{pep_outliers} object,
with each station plotted as a circle marker whose size encodes the
number of flagged observations and whose colour encodes the maximum
absolute residual (or Mahalanobis distance) for the station. Popups
list the worst-offending station-years and their residual values —
useful for interactive inspection during QC.
}
\details{
Unlike \code{\link{pheno_leaflet}} (which is a selection gadget built
on Shiny + miniUI), this is a pure visualisation: it returns a
\code{leaflet} htmlwidget so you can embed it in an R Markdown
report, include it in a vignette, or call \code{print()} on it for
interactive exploration.

\strong{Colour} encodes the station's maximum absolute residual
(for univariate methods: \code{max(|deviation|)} in days; for
\code{method = "mahalanobis"}: the maximum robust Mahalanobis
distance). \strong{Size} encodes \code{log1p(n_outliers)} — a station
flagged once has a small marker, a station flagged 30 times has a
much larger one.

For \code{method = "gam_residual"} and \code{"mahalanobis"} this is
the natural companion to the Schaber-Badeck-style text tables and
the static diagnostic figure, because spatial structure in outliers
(a local observer network, a regional climate anomaly) is often
only visible on a map.
}
\examples{
\dontrun{
pep <- pep_download()
pep_ch <- pep[country == "Switzerland" & species == "Malus domestica"]
flagged <- pep_flag_outliers(
  pep_ch,
  by = c("genus", "species", "phase_id"),
  method = "gam_residual"
)
pep_outliers_leaflet(flagged)
}

}
\seealso{
\code{\link{pep_flag_outliers}} — detection,
\code{\link{pep_plot_outliers}} — static diagnostic plots,
\code{\link{pheno_leaflet}} — station-selection Shiny gadget.
}
\author{
Matthias Templ
}
