% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/habitat_utils.R
\name{add_intertidal_flag}
\alias{add_intertidal_flag}
\title{Add an intertidal zone flag to a survey dataframe}
\usage{
add_intertidal_flag(
  df,
  max_port_dist_km = 75,
  depth_col = "depth",
  verbose = TRUE
)
}
\arguments{
\item{df}{Dataframe with \code{lat}, \code{lon}, and \code{depth} (chart-datum corrected)
columns. Typically the output of \code{\link[=auto_tidal_correct]{auto_tidal_correct()}} or
\code{\link[=correct_to_chart_datum]{correct_to_chart_datum()}}.}

\item{max_port_dist_km}{Numeric. Maximum distance to nearest harmonic port
in km (default 75). If the survey centroid is further than this from all
ports, the function falls back to a conservative intertidal window of 6 m
above CD and issues a warning.}

\item{depth_col}{Character. Name of the chart-datum depth column
(default \code{"depth"}).}

\item{verbose}{Logical. Print the nearest port name and derived MHWS
(default \code{TRUE}).}
}
\value{
The input dataframe with an added \code{intertidal_zone} column:
\itemize{
\item \code{"subtidal"}: depth > 0 m CD
\item \code{"intertidal"}: 0 m CD >= depth >= -MHWS_above_CD
\item \code{"supratidal"}: depth < -MHWS_above_CD
}
}
\description{
Classifies each survey location as intertidal, subtidal, or supratidal
based on its depth below Chart Datum (CD) and the tidal range at the
nearest harmonic reference port. Chart Datum is approximately Lowest
Astronomical Tide (LAT), so:
\itemize{
\item \strong{Subtidal:}    \code{depth > 0} (always submerged)
\item \strong{Intertidal:}  \verb{-MHWS_above_CD <= depth <= 0}
(exposed at some states of the tide; depth is at or above CD)
\item \strong{Supratidal:}  \code{depth < -MHWS_above_CD}
(above the highest astronomical tide; excluded from scoring)
}

MHWS above CD is approximated from the harmonic constituents of the
nearest port as: \code{Z0 + 1.1 * (M2_H + S2_H)} -- the 10\% factor accounts
for minor constituents not included in the 5-constituent model.

This flag is used internally by \code{\link[=score_locations]{score_locations()}} to give \emph{Magallana
gigas} (Pacific oyster) full depth scores for intertidal cells, reflecting
its strong intertidal ecology in NW European waters.
}
\examples{
\donttest{
survey <- auto_tidal_correct(survey, datetime_col = "date")
survey <- add_intertidal_flag(survey)

# Check intertidal coverage
table(survey$intertidal_zone)
}
}
