% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/report-qgis.R
\name{report_to_qgis}
\alias{report_to_qgis}
\title{Export a classification result + pedon to a QGIS GeoPackage}
\usage{
report_to_qgis(
  pedon,
  classifications,
  file,
  report_html = NULL,
  overwrite = TRUE
)
}
\arguments{
\item{pedon}{A \code{\link{PedonRecord}}.}

\item{classifications}{A list of one to three
\code{\link{ClassificationResult}} objects, named
\code{wrb} / \code{sibcs} / \code{usda}. Pass the output of
\code{\link{classify_from_documents}} verbatim, or build
the list manually.}

\item{file}{Output path (\code{.gpkg}). Created with parents.}

\item{report_html}{Optional path to a sibling HTML report
(rendered via \code{\link{report_html}}) -- stored in the
\code{report_html} attribute of \code{pedon_point} so
QGIS users can launch the report from the feature pop-up.}

\item{overwrite}{If \code{TRUE} (default), an existing
\code{file} is replaced; otherwise an error is thrown.}
}
\value{
The output \code{file} path, invisibly. Side-effect:
        writes a multi-layer GeoPackage.
}
\description{
Writes a single GeoPackage (\code{.gpkg}) that QGIS reads
natively, containing one POINT layer (the profile location with
all classification metadata as attributes) plus two attribute-only
tables (the horizons schema and the provenance log). Lets a
pedologist overlay the soilKey result on a soil-survey base map
or join it with field-campaign vector data without writing R or
SQL.
}
\section{Geometry handling}{

The point geometry uses the pedon's site CRS
(\code{pedon$site$crs}, default EPSG:4326). When the site has no
coordinates, the function still writes the two attribute tables
but skips the point layer and emits a warning.
}

\section{Layer schema}{

\describe{
  \item{\code{pedon_point}}{site_id, country, year, lat, lon,
        crs, wrb_name, wrb_rsg, wrb_grade, wrb_principal,
        wrb_supplementary, sibcs_name, sibcs_ordem, sibcs_grade,
        usda_name, usda_order, usda_grade, n_horizons,
        report_html (relative path), generated_at.}
  \item{\code{horizons_table}}{site_id, horizon_idx, top_cm,
        bottom_cm, designation, plus the canonical
        \code{horizon_column_spec()} attributes when present.}
  \item{\code{provenance_log}}{site_id, horizon_idx, attribute,
        source, confidence, notes.}
}
}

\examples{
\donttest{
if (requireNamespace("sf", quietly = TRUE)) {
  pedon <- make_ferralsol_canonical()
  results <- list(
    wrb   = classify_wrb2022(pedon, on_missing = "silent"),
    sibcs = classify_sibcs(pedon, include_familia = TRUE),
    usda  = classify_usda(pedon)
  )
  out_gpkg <- file.path(tempdir(), "perfil_042.gpkg")
  report_to_qgis(pedon, results,
                 file        = out_gpkg,
                 report_html = file.path(tempdir(), "perfil_042.html"))
  # In QGIS: Layer -> Add Layer -> Add Vector Layer -> perfil_042.gpkg
}
}
}
\seealso{
\code{\link{report}} for HTML / PDF reports;
         \code{\link{classify_from_documents}} for the high-level
         one-liner that produces compatible \code{classifications}.
}
