% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/get_deps.R
\name{get_deps}
\alias{get_deps}
\title{Retrieve INSEE department codes from an sf object}
\usage{
get_deps(x)
}
\arguments{
\item{x}{An \code{sf} object defining the area(s) of interest.}
}
\value{
A \code{character} vector of unique INSEE department codes intersecting
the input geometries. Returns \code{NULL} if no intersection is found or if the
WFS request fails.
}
\description{
This function retrieves the INSEE administrative department codes
(\code{code_insee}) intersecting the features of a given \code{sf} object.
It relies on the \emph{Admin Express COG} WFS service provided by IGN,
accessed via the \strong{happign} package.
}
\details{
The function performs the following steps:
\enumerate{
\item Transforms the input geometries to CRS:4326.
\item Computes centroids of the geometries.
\item Queries the IGN WFS service (\emph{Admin Express COG}) to retrieve departments.
\item Performs a spatial join using \code{\link[sf:geos_binary_pred]{sf::st_intersects()}}.
\item Extracts and returns unique \code{code_insee} values.
}

Notes:
\itemize{
\item The function depends on the availability of the IGN WFS service.
\item Large or complex geometries may cause the request to fail.
\item In such cases, consider simplifying or reducing the spatial extent of \code{x}.
}
}
\examples{
\donttest{
if (interactive()) {

  # Minimal sf object (point in Paris)
  x <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.35, 48.85)),
      crs = 4326
    )
  )

  # Retrieve department code
  get_deps(x)

  # Multiple locations (Paris and Rouen)
  x2 <- sf::st_sf(
    geometry = sf::st_sfc(
      sf::st_point(c(2.35, 48.85)),  # 75
      sf::st_point(c(1.09, 49.44)),  # 76
      crs = 4326
    )
  )

  get_deps(x2)

}
}

}
