diff --git a/NAMESPACE b/NAMESPACE index a4a1b4076b8e8fdd133c2f970d6a671a37be6d00..0bf79c9ae6071cfd10192d43e6ca273429e77e9e 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -2,6 +2,7 @@ export(doApiQuery) export(get_available_params) +export(get_hydrometrie_stations) export(get_indicateurs_services_communes) export(get_indicateurs_services_indicateurs) export(get_prelevements_chroniques) diff --git a/R/get_hydrometrie_stations.R b/R/get_hydrometrie_stations.R new file mode 100644 index 0000000000000000000000000000000000000000..8e7899e4c057b3c8b7802c0211f321a4217d958b --- /dev/null +++ b/R/get_hydrometrie_stations.R @@ -0,0 +1,29 @@ +#' Retrieve hydrometric stations from API "Hydrométrie" +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie} +#' +#' @template param_get_common +#' @param code_sandre_reseau_station optional [logical] indicating if `code_sandre_reseau_station` field is included in the result; if so, one line is added by item and other fields are repeated +#' +#' @return a [tibble::tibble] with all available parameters in columns and one row by device, year and usage. +#' @export +#' +#' @examples +#' # For retrieving the hydrometric stations in the department of Aube +#' get_hydrometrie_stations(list(code_departement = "10")) +#' +get_hydrometrie_stations <- function(params, code_sandre_reseau_station = FALSE, cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + l <- doApiQuery(api = "hydrometrie", + operation = "stations", + params = params, + cfg = cfg) + l <- lapply(l, function(x) { + if (!code_sandre_reseau_station) { + x$code_sandre_reseau_station <- NULL + } + x$geometry <- NULL + x + }) + convert_list_to_tibble(l) +} diff --git a/R/hubeau.R b/R/hubeau.R index 3ba2d41fafae8d39614154086e0ceea18af709c3..d994ce5b7d83c6a346d4c8be2b0d8a5352eaa8b1 100644 --- a/R/hubeau.R +++ b/R/hubeau.R @@ -4,6 +4,14 @@ #' #' Currently available APIs and related "operations" are listed below. #' +#' **API "Hydrométrie"** +#' +#' API documentation: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie} +#' +#' Available functions: +#' +#' - [get_hydrometrie_stations] +#' #' **API "Indicateurs des services"** #' #' API documentation: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services} @@ -20,6 +28,7 @@ #' Available functions: #' #' - [get_prelevements_chroniques] +#' - [get_prelevements_ouvrages] #' - [get_prelevements_points_prelevement] #' #' @docType package diff --git a/inst/config.yml b/inst/config.yml index 47c8e6ad51df52fa2c1b6dc6ecf1d0b27ac39684..542126d5c059a982bcbb82e26fb7b88ec2387e65 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -95,3 +95,27 @@ default: - code_departement - fields - type_service + hydrometrie: + path: v1/hydrometrie + operations: + stations: + path: referentiel/stations + fields: + - bbox + - code_commune_station + - code_cours_eau + - code_departement + - code_region + - code_sandre_reseau_station + - code_site + - code_station + - date_fermeture_station + - date_ouverture_station + - distance + - en_service + - fields + - latitude + - libelle_cours_eau + - libelle_site + - libelle_station + - longitude diff --git a/man/get_hydrometrie_stations.Rd b/man/get_hydrometrie_stations.Rd new file mode 100644 index 0000000000000000000000000000000000000000..8f8b1c1a33a9db7ca5bc4884a1aac57bda701510 --- /dev/null +++ b/man/get_hydrometrie_stations.Rd @@ -0,0 +1,31 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_hydrometrie_stations.R +\name{get_hydrometrie_stations} +\alias{get_hydrometrie_stations} +\title{Retrieve hydrometric stations from API "Hydrométrie"} +\usage{ +get_hydrometrie_stations( + params, + code_sandre_reseau_station = FALSE, + cfg = config::get(file = system.file("config.yml", package = "hubeau")) +) +} +\arguments{ +\item{params}{a \link{list} the list of parameters of the queries and their values in the format \code{list(ParamName = "Param value", ...)}, use the function \link{get_available_params} for a list of the available parameters for a given operation in an API and see the API documentation for the complete list of available filter parameters} + +\item{code_sandre_reseau_station}{optional \link{logical} indicating if \code{code_sandre_reseau_station} field is included in the result; if so, one line is added by item and other fields are repeated} + +\item{cfg}{a \link{config} object Configuration of the communication. Use by default the internal package +configuration} +} +\value{ +a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by device, year and usage. +} +\description{ +See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie} +} +\examples{ +# For retrieving the hydrometric stations in the department of Aube +get_hydrometrie_stations(list(code_departement = "10")) + +} diff --git a/man/hubeau.Rd b/man/hubeau.Rd index 3de365ccb8b2369475ea62d0c953d29984a2d26e..130be14dfb7bad43e9a92851b3700b19140f93b0 100644 --- a/man/hubeau.Rd +++ b/man/hubeau.Rd @@ -10,6 +10,15 @@ The 'hubeau' package provides functions for APIs and related "operations". These \details{ Currently available APIs and related "operations" are listed below. +\strong{API "Hydrométrie"} + +API documentation: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie} + +Available functions: +\itemize{ +\item \link{get_hydrometrie_stations} +} + \strong{API "Indicateurs des services"} API documentation: \url{https://hubeau.eaufrance.fr/page/api-indicateurs-services} @@ -27,6 +36,7 @@ API documentation: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau} Available functions: \itemize{ \item \link{get_prelevements_chroniques} +\item \link{get_prelevements_ouvrages} \item \link{get_prelevements_points_prelevement} } }