% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/larval_dispersal.R
\name{parse_opendrift_connectivity}
\alias{parse_opendrift_connectivity}
\title{Parse an OpenDrift particle tracking output into a connectivity matrix}
\usage{
parse_opendrift_connectivity(
  opendrift_csv,
  bin_deg = 0.05,
  status_col = NULL,
  status_keep = c("stranded", "settled"),
  min_weight = 0.005,
  verbose = TRUE
)
}
\arguments{
\item{opendrift_csv}{Character. Path to OpenDrift settlement CSV file. Must
contain columns \code{origin_lat}, \code{origin_lon}, \code{final_lat}, \code{final_lon}.}

\item{bin_deg}{Numeric. Grid cell size in decimal degrees for binning
(default 0.05 approx. 5 km at mid-latitudes).}

\item{status_col}{Character or NULL. Name of a status column to filter on.
If NULL (default), all rows are used.}

\item{status_keep}{Character. Value(s) of \code{status_col} to include
(default \code{c("stranded","settled")}).}

\item{min_weight}{Numeric. Minimum connectivity weight to include in output
(default 0.005 = 0.5 percent). Filters very weak connections.}

\item{verbose}{Logical. Default TRUE.}
}
\value{
A dataframe with columns \code{source_lat}, \code{source_lon}, \code{dest_lat},
\code{dest_lon}, \code{weight} -- ready for passing to
\code{\link[=score_larval_connectivity]{score_larval_connectivity()}}.
}
\description{
Converts the output of an OpenDrift settlement simulation (a CSV file with
particle origin and final position) into the connectivity matrix format
expected by \code{score_larval_connectivity(connectivity_matrix = ...)}.

\strong{OpenDrift setup:}
Run OpenDrift (\code{OceanDrift} or \code{OpenOil} adapted for larvae) seeding particles
at each source reef location. Export a CSV with at minimum:
\itemize{
\item \code{origin_lat}, \code{origin_lon} -- seed position
\item \code{final_lat}, \code{final_lon} -- settlement position (stranded or settled)
\item \code{status} -- filter to \code{"stranded"} or \code{"active"} as appropriate
}

The function bins particles into a grid and computes the fraction of particles
from each source bin that arrive in each destination bin.
}
\examples{
\dontrun{
# After running OpenDrift simulation and exporting CSV:
cm <- parse_opendrift_connectivity("opendrift_output.csv", bin_deg = 0.05)

result <- predict_oyster(survey, "ostrea_edulis")
result <- score_larval_connectivity(result,
            species             = "ostrea_edulis",
            connectivity_matrix = cm)
}
}
