From 73c95280305fe3761d3374d4bb885b5744cd21dc Mon Sep 17 00:00:00 2001 From: Dorchies David <david.dorchies@inrae.fr> Date: Fri, 6 Aug 2021 09:36:53 +0200 Subject: [PATCH] feat: add `get_niveaux_nappes_stations` Refs #8 --- NAMESPACE | 1 + R/get_hydrometrie_stations.R | 2 +- R/get_niveaux_nappes_stations.R | 25 ++++++++++++++++ R/hubeau.R | 8 +++++ inst/config.yml | 47 ++++++++++++++++++++++++++++++ man/get_hydrometrie_stations.Rd | 2 +- man/get_niveaux_nappes_stations.Rd | 28 ++++++++++++++++++ man/hubeau.Rd | 9 ++++++ 8 files changed, 120 insertions(+), 2 deletions(-) create mode 100644 R/get_niveaux_nappes_stations.R create mode 100644 man/get_niveaux_nappes_stations.Rd diff --git a/NAMESPACE b/NAMESPACE index 09c1aa3..8342d3c 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -7,6 +7,7 @@ export(get_hydrometrie_sites) export(get_hydrometrie_stations) export(get_indicateurs_services_communes) export(get_indicateurs_services_indicateurs) +export(get_niveaux_nappes_stations) export(get_prelevements_chroniques) export(get_prelevements_ouvrages) export(get_prelevements_points_prelevement) diff --git a/R/get_hydrometrie_stations.R b/R/get_hydrometrie_stations.R index 8e7899e..fd4286a 100644 --- a/R/get_hydrometrie_stations.R +++ b/R/get_hydrometrie_stations.R @@ -5,7 +5,7 @@ #' @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. +#' @return a [tibble::tibble] with all available parameters in columns and one row by station. #' @export #' #' @examples diff --git a/R/get_niveaux_nappes_stations.R b/R/get_niveaux_nappes_stations.R new file mode 100644 index 0000000..e8884ee --- /dev/null +++ b/R/get_niveaux_nappes_stations.R @@ -0,0 +1,25 @@ +#' Retrieve piezometric stations from API "Piézométrie" +#' +#' See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +#' +#' @template param_get_common +#' +#' @return a [tibble::tibble] with all available parameters in columns and one row by station. +#' @export +#' +#' @examples +#' # For retrieving the hydrometric stations in the department of Aube +#' get_niveaux_nappes_stations(list(code_departement = "10")) +#' +get_niveaux_nappes_stations <- function(params, cfg = config::get(file = system.file("config.yml", + package = "hubeau"))) { + l <- doApiQuery(api = "niveaux_nappes", + operation = "stations", + params = params, + cfg = cfg) + l <- lapply(l, function(x) { + x$geometry <- NULL + x + }) + convert_list_to_tibble(l) +} diff --git a/R/hubeau.R b/R/hubeau.R index afb1eec..5ec0d15 100644 --- a/R/hubeau.R +++ b/R/hubeau.R @@ -23,6 +23,14 @@ #' - [get_indicateurs_services_communes] #' - [get_indicateurs_services_indicateurs] #' +#' **API "Piézométrie"** +#' +#' API documentation: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +#' +#' Available functions: +#' +#' - [get_niveaux_nappes_stations] +#' #' **API "Prélèvements en eau"** #' #' API documentation: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau} diff --git a/inst/config.yml b/inst/config.yml index 55ff964..9d15239 100644 --- a/inst/config.yml +++ b/inst/config.yml @@ -150,3 +150,50 @@ default: - latitude - longitude - timestep + niveaux_nappes: + path: v1/niveaux_nappes + operations: + stations: + path: stations + fields: + - bbox + - bss_id + - code_bdlisa + - code_bss + - code_commune + - code_departement + - codes_masse_eau_edl + - date_recherche + - fields + - srid + sites: + path: referentiel/sites + fields: + - bbox + - code_commune_site + - code_cours_eau + - code_departement + - code_region + - code_site + - code_troncon_hydro_site + - code_zone_hydro_site + - distance + - fields + - latitude + - libelle_cours_eau + - libelle_site + - longitude + observations_tr: + path: observations_tr + fields: + - bbox + - code_entite + - cursor + - date_debut_obs + - date_fin_obs + - distance + - fields + - grandeur_hydro + - latitude + - longitude + - timestep diff --git a/man/get_hydrometrie_stations.Rd b/man/get_hydrometrie_stations.Rd index 8f8b1c1..029f6b8 100644 --- a/man/get_hydrometrie_stations.Rd +++ b/man/get_hydrometrie_stations.Rd @@ -19,7 +19,7 @@ get_hydrometrie_stations( configuration} } \value{ -a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by device, year and usage. +a \link[tibble:tibble]{tibble::tibble} with all available parameters in columns and one row by station. } \description{ See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-hydrometrie} diff --git a/man/get_niveaux_nappes_stations.Rd b/man/get_niveaux_nappes_stations.Rd new file mode 100644 index 0000000..279e1a1 --- /dev/null +++ b/man/get_niveaux_nappes_stations.Rd @@ -0,0 +1,28 @@ +% Generated by roxygen2: do not edit by hand +% Please edit documentation in R/get_niveaux_nappes_stations.R +\name{get_niveaux_nappes_stations} +\alias{get_niveaux_nappes_stations} +\title{Retrieve piezometric stations from API "Piézométrie"} +\usage{ +get_niveaux_nappes_stations( + params, + 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{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 station. +} +\description{ +See the API documentation for available filter parameters: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} +} +\examples{ +# For retrieving the hydrometric stations in the department of Aube +get_niveaux_nappes_stations(list(code_departement = "10")) + +} diff --git a/man/hubeau.Rd b/man/hubeau.Rd index 312ba33..7287b20 100644 --- a/man/hubeau.Rd +++ b/man/hubeau.Rd @@ -31,6 +31,15 @@ Available functions: \item \link{get_indicateurs_services_indicateurs} } +\strong{API "Piézométrie"} + +API documentation: \url{https://hubeau.eaufrance.fr/page/api-piezometrie} + +Available functions: +\itemize{ +\item \link{get_niveaux_nappes_stations} +} + \strong{API "Prélèvements en eau"} API documentation: \url{https://hubeau.eaufrance.fr/page/api-prelevements-eau} -- GitLab