% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/ingest_sensors.R
\name{merge_sensor_data}
\alias{merge_sensor_data}
\title{Merge multiple sensor datasets into a single survey table}
\usage{
merge_sensor_data(..., spatial_res = 4L, date_source = NULL, verbose = TRUE)
}
\arguments{
\item{...}{Two or more dataframes to merge. Each must contain \code{lat} and \code{lon}
columns. Pass them as named arguments for cleaner messages (e.g.
\verb{adcp = adcp_df, biobase = biobase_df}).

\strong{Multiple runs of the same sensor:} If you have several surveys from the
same sensor type, pass them as a list and they will be automatically
stacked via \code{\link[=stack_surveys]{stack_surveys()}} before merging:

\if{html}{\out{<div class="sourceCode r">}}\preformatted{merge_sensor_data(
  adcp    = list(adcp_run1, adcp_run2, adcp_run3),
  bathy   = bathy_df,
  biobase = biobase_df
)
}\if{html}{\out{</div>}}}

\item{spatial_res}{Integer. Decimal places for the common spatial grid
(default \code{4}, approx.11 m at 56degrees N). Must be the same or coarser than the
resolution used when reading each individual sensor.}

\item{date_source}{Character. Name of the dataset to take the \code{date} column
from (default \code{NULL} -- uses the first dataset that contains a \code{date}
column).}

\item{verbose}{Logical. Print a merge summary (default \code{TRUE}).}
}
\value{
A single dataframe with all oystermapR-compatible columns populated
from their respective sensor sources. Columns that weren't available from
any sensor will be absent from the result -- \code{\link[=predict_oyster]{predict_oyster()}} handles
missing columns gracefully.
}
\description{
Takes any number of sensor dataframes (from \code{\link[=read_nortek_adcp]{read_nortek_adcp()}},
\code{\link[=read_generic_csv]{read_generic_csv()}}, or custom sources) and merges them spatially into a
single table ready for \code{\link[=predict_oyster]{predict_oyster()}}.

Each dataset is first rounded to a common spatial resolution grid. Datasets
are then joined using the grid cell key -- cells that exist in multiple
datasets are merged; cells that exist in only one dataset carry \code{NA} for
variables from other sensors.
}
\examples{
\donttest{
# Single run per sensor
adcp    <- read_nortek_adcp("adcp.csv")
biobase <- read_generic_csv("biobase.csv")
survey  <- merge_sensor_data(adcp = adcp, biobase = biobase)

# Multiple ADCP runs (different survey days) -- automatically stacked
adcp1  <- read_nortek_adcp("survey_jan.csv")
adcp2  <- read_nortek_adcp("survey_feb.csv")
survey <- merge_sensor_data(adcp = list(adcp1, adcp2), biobase = biobase)

result <- predict_oyster(survey, "ostrea_edulis", output_geotiff = "map.tif")
}
}
