diff --git a/.Rbuildignore b/.Rbuildignore index 0ee3a616..103fe4c8 100644 --- a/.Rbuildignore +++ b/.Rbuildignore @@ -16,3 +16,4 @@ ^Meta$ ^attic$ ^codemeta\.json$ +^vignettes/EMODnetWFS\.Rmd\.orig$ diff --git a/DESCRIPTION b/DESCRIPTION index 24e6851e..61658981 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -4,7 +4,7 @@ Version: 2.0.1.9001 Authors@R: c( person("Anna", "Krystalli", , "annakrystalli@googlemail.com", role = "aut", comment = c(ORCID = "0000-0002-2378-4915")), - person("Salvador", "Fernández-Bejarano", , "salvador.fernandez@vliz.be", role = c("ctb", "cre"), + person("Salvador", "Fernández-Bejarano", , "salvador.fernandez@vliz.be", role = c("aut", "cre"), comment = c(ORCID = "0000-0003-0535-7677")), person("Thomas J", "Webb", , "t.j.webb@sheffield.ac.uk", role = "ctb"), person("European Marine Observation Data Network (EMODnet) Biology project", "European Commission's Directorate - General for Maritime Affairs and Fisheries (DG MARE)", , "bio@emodnet.eu", role = "cph"), @@ -15,7 +15,8 @@ Authors@R: c( Description: Access and interrogate EMODnet Web Feature Service data through R. License: MIT + file LICENSE -URL: https://emodnet.github.io/EMODnetWFS/, https://github.com/EMODnet/EMODnetWFS +URL: https://emodnet.github.io/EMODnetWFS/, + https://github.com/EMODnet/EMODnetWFS BugReports: https://github.com/EMODnet/EMODnetWFS/issues Depends: R (>= 3.6.0) @@ -28,7 +29,7 @@ Imports: lifecycle, magrittr, memoise, - ows4R (>= 0.3), + ows4R (>= 0.3-4), purrr, rlang, sf, @@ -48,6 +49,8 @@ Suggests: testthis, webmockr, withr +VignetteBuilder: + knitr Remotes: eblondel/ows4R, nealrichardson/httptest, @@ -55,7 +58,6 @@ Remotes: Config/testthat/edition: 3 Encoding: UTF-8 LazyData: true -VignetteBuilder: knitr Roxygen: list(markdown = TRUE) RoxygenNote: 7.2.3 SystemRequirements: C++11, GDAL (>= 2.0.1), GEOS (>= 3.4.0), PROJ (>= diff --git a/R/EMODnetWFS-package.R b/R/EMODnetWFS-package.R index 8c5219ab..c3f5a912 100644 --- a/R/EMODnetWFS-package.R +++ b/R/EMODnetWFS-package.R @@ -15,19 +15,33 @@ emodnetwfs_user_agent <- function() { version <- as.character(utils::packageVersion("EMODnetWFS")) if (nzchar(Sys.getenv("EMODNETWFS_CI"))) { - return(sprintf("EMODnetWFS R package %s CI https://github.com/EMODnet/EMODnetWFS", version)) + return( + sprintf( + "EMODnetWFS R package %s CI https://github.com/EMODnet/EMODnetWFS", + version + ) + ) } gh_username <- try(whoami::gh_username(), silent = TRUE) - if (!inherits(gh_username, "try-error") && gh_username %in% emodnetwfs_collaborators()) { - return(sprintf("EMODnetWFS R package %s DEV https://github.com/EMODnet/EMODnetWFS", version)) + if (!inherits(gh_username, "try-error") && + gh_username %in% emodnetwfs_collaborators()) { + return( + sprintf( + "EMODnetWFS R package %s DEV https://github.com/EMODnet/EMODnetWFS", + version + ) + ) } - sprintf("EMODnetWFS R package %s https://github.com/EMODnet/EMODnetWFS", version) + sprintf( + "EMODnetWFS R package %s https://github.com/EMODnet/EMODnetWFS", + version + ) } globalVariables(c("layer_name", "n")) release_bullets <- function() { - c('update vignette with knitr::knit("vignettes/EMODnetWFS.Rmd.orig", output = "vignettes/EMODnetWFS.Rmd")') + c('update vignette with knitr::knit("vignettes/EMODnetWFS.Rmd.orig", output = "vignettes/EMODnetWFS.Rmd")') } diff --git a/R/client.R b/R/client.R index 57561cd2..b82fc04b 100644 --- a/R/client.R +++ b/R/client.R @@ -2,11 +2,14 @@ #' #' @param service the EMODnet OGC WFS service name. #' For available services, see [`emodnet_wfs()`]. -#' @param service_version `r lifecycle::badge('deprecated')` the WFS service version. Now always "2.0.0". -#' @param logger the logger. Either `NULL` (no logging info), `"INFO"` (log about ows4R requests) +#' @param service_version `r lifecycle::badge('deprecated')` +#' the WFS service version. Now always "2.0.0". +#' @param logger the logger. Either `NULL` (no logging info), `"INFO"` +#' (log about ows4R requests) #' or `"DEBUG"` (including curl details). #' -#' @return An [`ows4R::WFSClient`] R6 object with methods for interfacing an OGC Web Feature Service. +#' @return An [`ows4R::WFSClient`] R6 object with methods for interfacing an +#' OGC Web Feature Service. #' @export #' #' @seealso `WFSClient` in package `ows4R`. @@ -14,8 +17,13 @@ #' \dontrun{ #' wfs <- emodnet_init_wfs_client(service = "bathymetry") #' } -emodnet_init_wfs_client <- function(service, service_version = NULL, logger = NULL) { - deprecate_message_service_version(service_version, "deprecate_message_service_version") +emodnet_init_wfs_client <- function(service, + service_version = NULL, + logger = NULL) { + deprecate_message_service_version( + service_version, + "deprecate_message_service_version" + ) check_service_name(service) @@ -97,12 +105,18 @@ check_service <- function(request) { if (httr::http_error(request)) { cli_alert_danger("HTTP Status: {httr::http_status(request)$message}") - is_monitor_up <- !is.null(curl::nslookup("monitor.emodnet.eu", error = FALSE)) + is_monitor_up <- !is.null( + curl::nslookup("monitor.emodnet.eu", error = FALSE) + ) if (interactive() && is_monitor_up) { - browse_monitor <- utils::askYesNo("Browse the EMODnet OGC monitor?", FALSE, prompts = "yes/no/cancel") + browse_monitor <- utils::askYesNo( + "Browse the EMODnet OGC monitor?", + FALSE, + prompts = "yes/no/cancel" + ) if (is.na(browse_monitor)) browse_monitor <- FALSE if (browse_monitor) { - utils::browseURL("https://monitor.emodnet.eu/resources?lang=en&resource_type=OGC:WFS") + utils::browseURL("https://monitor.emodnet.eu/resources?lang=en&resource_type=OGC:WFS") # nolint } } @@ -115,7 +129,7 @@ check_service <- function(request) { cli::cli_abort( c( "An exception has occurred.", - i = "Please raise an issue in {packageDescription('EMODnetWFS')$BugReports}" + i = "Please raise an issue in {packageDescription('EMODnetWFS')$BugReports}" # nolint ) ) } diff --git a/R/info.R b/R/info.R index 7eb59f79..1055e56f 100644 --- a/R/info.R +++ b/R/info.R @@ -32,11 +32,15 @@ #' @importFrom memoise memoise #' @details To minimize the number of requests sent to webservices, #' these functions use `memoise` to cache results inside the active R session. -#' To clear the cache, re-start R or run `memoise::forget(emodnet_get_wfs_info)`/`memoise::forget(emodnet_get_layer_info)`. +#' To clear the cache, re-start R or +#' run `memoise::forget(emodnet_get_wfs_info)`/ +#' `memoise::forget(emodnet_get_layer_info)`. #' @export emodnet_get_layer_info <- memoise::memoise(.emodnet_get_layer_info) -.emodnet_get_wfs_info <- function(wfs = NULL, service = NULL, service_version = NULL) { +.emodnet_get_wfs_info <- function(wfs = NULL, + service = NULL, + service_version = NULL) { deprecate_message_service_version(service_version, "emodnet_get_wfs_info") if (is.null(wfs) && is.null(service)) { @@ -59,7 +63,10 @@ emodnet_get_layer_info <- memoise::memoise(.emodnet_get_layer_info) service_url = capabilities$getUrl(), layer_name = purrr::map_chr(capabilities$getFeatureTypes(), ~ .x$getName()), title = purrr::map_chr(capabilities$getFeatureTypes(), ~ .x$getTitle()), - abstract = purrr::map_chr(capabilities$getFeatureTypes(), ~ get_abstract_null(.x)), + abstract = purrr::map_chr( + capabilities$getFeatureTypes(), + ~ get_abstract_null(.x) + ), class = purrr::map_chr(capabilities$getFeatureTypes(), ~ .x$getClassName()), format = purrr::map_chr(capabilities$getFeatureTypes(), guess_layer_format) ) %>% @@ -71,11 +78,14 @@ emodnet_get_layer_info <- memoise::memoise(.emodnet_get_layer_info) } #' Get WFS available layer information #' -#' @param wfs A `WFSClient` R6 object with methods for interfacing an OGC Web Feature Service. +#' @param wfs A `WFSClient` R6 object with methods for interfacing an +#' OGC Web Feature Service. #' @inheritParams emodnet_init_wfs_client -#' @return a tibble containing metadata on each layer available from the service. +#' @return a tibble containing metadata on each layer available from the +#' service. #' @export -#' @describeIn emodnet_get_wfs_info Get info on all layers from am EMODnet WFS service. +#' @describeIn emodnet_get_wfs_info Get info on all layers from +#' an EMODnet WFS service. #' @examples #' \dontrun{ #' emodnet_get_wfs_info(service = "bathymetry") diff --git a/R/layer_attributes.R b/R/layer_attributes.R index bc87b62c..f36744ea 100644 --- a/R/layer_attributes.R +++ b/R/layer_attributes.R @@ -5,18 +5,25 @@ #' @param layer character sting of layer name. To get info on layers, including #' `layer_name` use [emodnet_get_wfs_info()]. #' -#' @return output of `summary()` on the attributes (variables) in a given layer for a given service. +#' @return output of `summary()` on the attributes (variables) in a given layer +#' for a given service. #' @export #' #' @examples #' \dontrun{ -#' layer_attributes_summarise(service = "human_activities", layer = "maritimebnds") +#' layer_attributes_summarise( +#' service = "human_activities", +#' layer = "maritimebnds" +#' ) #' } layer_attributes_summarise <- function(wfs = NULL, service = NULL, service_version = NULL, layer) { - deprecate_message_service_version(service_version, "layer_attributes_summarise") + deprecate_message_service_version( + service_version, + "layer_attributes_summarise" + ) summary( layer_attributes_tbl( wfs = wfs, @@ -37,12 +44,18 @@ layer_attributes_summarise <- function(wfs = NULL, #' #' @examples #' \dontrun{ -#' layer_attribute_descriptions(service = "human_activities", layer = "maritimebnds") +#' layer_attribute_descriptions( +#' service = "human_activities", +#' layer = "maritimebnds" +#' ) #' } layer_attribute_descriptions <- function(wfs = NULL, service = NULL, service_version = NULL, layer) { - deprecate_message_service_version(service_version, "layer_attribute_descriptions") + deprecate_message_service_version( + service_version, + "layer_attribute_descriptions" + ) wfs <- wfs %||% emodnet_init_wfs_client(service) check_wfs(wfs) @@ -62,13 +75,19 @@ layer_attribute_descriptions <- function(wfs = NULL, #' #' @examples #' \dontrun{ -#' layer_attributes_get_names(service = "human_activities", layer = "maritimebnds") +#' layer_attributes_get_names( +#' service = "human_activities", +#' layer = "maritimebnds" +#' ) #' } layer_attributes_get_names <- function(wfs = NULL, service = NULL, service_version = NULL, layer) { - deprecate_message_service_version(service_version, "layer_attributes_get_names") + deprecate_message_service_version( + service_version, + "layer_attributes_get_names" + ) layer_attribute_descriptions( wfs = wfs, @@ -85,7 +104,8 @@ layer_attributes_get_names <- function(wfs = NULL, #' @inheritParams emodnet_init_wfs_client #' @inheritParams emodnet_get_wfs_info #' -#' @return Detailed summary of individual attribute (variable). Particularly useful for inspecting +#' @return Detailed summary of individual attribute (variable). Particularly +#' useful for inspecting #' factor or character variable levels or unique values. #' @export #' @@ -116,7 +136,10 @@ layer_attribute_inspect <- function(wfs = NULL, choices = layer_attributes_get_names(wfs, layer = layer) ) - attribute_vector <- wfs$getFeatures(namespaced_layer, PROPERTYNAME = attribute)[[attribute]] + attribute_vector <- wfs$getFeatures( + namespaced_layer, + PROPERTYNAME = attribute + )[[attribute]] if (inherits(attribute_vector, "sfc")) { attribute_type <- "geometry" @@ -141,9 +164,12 @@ layer_attribute_inspect <- function(wfs = NULL, #' @inheritParams emodnet_get_wfs_info #' @inheritParams layer_attributes_summarise #' -#' @return tibble of layer attribute (variable) values with geometry column removed. -#' @details Request excluding spatial information can be significantly faster. Can be -#' useful for inspecting attribute values and constructing feature filters for more +#' @return tibble of layer attribute (variable) values +#' with geometry column removed. +#' @details Request excluding spatial information can be significantly faster. +#' Can be +#' useful for inspecting attribute values and constructing feature filters +#' for more #' targeted and faster layer download. #' @export #' @@ -168,7 +194,10 @@ layer_attributes_tbl <- function(wfs = NULL, attributes <- layer_attributes_get_names(wfs, layer = layer) attributes <- attributes[attributes != get_layer_geom_name(layer, wfs)] - wfs$getFeatures(namespaced_layer, PROPERTYNAME = paste(attributes, collapse = ",")) %>% + wfs$getFeatures( + namespaced_layer, + PROPERTYNAME = paste(attributes, collapse = ",") + ) %>% sf::st_drop_geometry() %>% tibble::as_tibble() } @@ -196,7 +225,9 @@ get_layer_geom_name <- function(layer, wfs) { desc$name[desc$type == "geometry"] } -get_layer_default_crs <- function(layer, wfs, output = c("crs", "epsg.text", "epsg.num")) { +get_layer_default_crs <- function(layer, + wfs, + output = c("crs", "epsg.text", "epsg.num")) { check_wfs(wfs) output <- match.arg(output, several.ok = FALSE) @@ -211,7 +242,10 @@ get_layer_default_crs <- function(layer, wfs, output = c("crs", "epsg.text", "ep return(crs) } - epsg.text <- regmatches(crs$input, regexpr("epsg\\:[[:digit:]]{4}", crs$input)) + epsg.text <- regmatches( + crs$input, + regexpr("epsg\\:[[:digit:]]{4}", crs$input) + ) if (output == "epsg.text") { return(epsg.text) } diff --git a/R/layers.R b/R/layers.R index c5562da2..5a16c142 100644 --- a/R/layers.R +++ b/R/layers.R @@ -5,13 +5,15 @@ #' of layer features can also be handled via ECQL language filters. #' @inheritParams emodnet_init_wfs_client #' @inheritParams emodnet_get_wfs_info -#' @param layers a character vector of layer names. To get info on layers, including +#' @param layers a character vector of layer names. To get info on layers, +#' including #' `layer_name` use [emodnet_get_wfs_info()]. #' @param crs integer. EPSG code for the output crs. If `NULL` (default), layers #' are returned with original crs. #' @param cql_filter character. Features returned can be filtered using valid #' Extended Common Query Language (ECQL) filtering statements -#' (). Should be one of: +#' (). +#' Should be one of: #' \itemize{ #' \item{character string or character vector of length 1. #' Filter will be recycled across all layers requested} @@ -24,7 +26,8 @@ #' Layers without corresponding filters are returned whole } #' } #' @param reduce_layers whether to reduce output layers to a single `sf` object. -#' @param ... additional vendor parameter arguments passed to [`ows4R::GetFeature()`](https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature). +#' @param ... additional vendor parameter arguments passed to +#' [`ows4R::GetFeature()`](https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature).# nolint #' For example, including `count=1` returns the first available feature. #' @return If `reduce_layers = FALSE` (default), a list of `sf` #' objects, one element for each layer. Any layers for which download was @@ -64,8 +67,12 @@ #' reduce_layers = TRUE #' ) #' } -emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = NULL, - layers, crs = NULL, cql_filter = NULL, +emodnet_get_layers <- function(wfs = NULL, + service = NULL, + service_version = NULL, + layers, + crs = NULL, + cql_filter = NULL, reduce_layers = FALSE, ...) { deprecate_message_service_version(service_version, "emodnet_get_layers") @@ -96,7 +103,7 @@ emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = NUL cli::cli_abort( c( "Can't reduce layers when one is a data.frame", - i = 'data.frame layer(s): {.val {toString(layers[formats == "data.frame"])}}' + i = 'data.frame layer(s): {.val {toString(layers[formats == "data.frame"])}}' # nolint ) ) } @@ -119,9 +126,10 @@ emodnet_get_layers <- function(wfs = NULL, service = NULL, service_version = NUL # get features ------------------------------------------------------------- - # unnamed function and explicit passing of ellipses used because of idiosyncratic use of ... + # unnamed function and explicit passing of ellipses used + # because of idiosyncratic use of ... # within purrr::map2 function. - # See: https://stackoverflow.com/questions/48215325/passing-ellipsis-arguments-to-map-function-purrr-package-r + # See: https://stackoverflow.com/questions/48215325/passing-ellipsis-arguments-to-map-function-purrr-package-r # nolint out <- purrr::map2( .x = layers, .y = cql_filter, .f = function(x, y, wfs, ...) { @@ -164,14 +172,14 @@ check_layer_crs <- function(layer_sf, layer, wfs) { wfs_crs <- get_layer_default_crs(layer, wfs) if (is.na(wfs_crs) || is.null(wfs_crs)) { - # If full crs object not available, try to get epsg number from identifier of - # the default CRS for this feature type in service description CRS + # If full crs object not available, try to get epsg number from identifier + # ofthe default CRS for this feature type in service description CRS wfs_crs <- get_layer_default_crs(layer, wfs, output = "epsg.num") } if (!is.na(wfs_crs) && !is.null(wfs_crs)) { - # If full crs object not available, try to get epsg number from identifier of - # the default CRS for this feature type in service description CRS + # If full crs object not available, try to get epsg number from identifier + # ofthe default CRS for this feature type in service description CRS sf::st_crs(layer_sf) <- wfs_crs } @@ -239,7 +247,11 @@ ews_get_layer <- function(x, wfs, cql_filter = NULL, ...) { # get layer using cql_filter tryCatch( { - layer <- wfs$getFeatures(namespaced_x, cql_filter = utils::URLencode(cql_filter), ...) + layer <- wfs$getFeatures( + namespaced_x, + cql_filter = utils::URLencode(cql_filter), + ... + ) if (inherits(layer, "sf")) { layer <- check_layer_crs(layer, layer = x, wfs = wfs) diff --git a/README.Rmd b/README.Rmd index 661aa413..22a3a57e 100644 --- a/README.Rmd +++ b/README.Rmd @@ -19,10 +19,11 @@ options(timeout = 2000) [![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html) [![R build status](https://github.com/EMODnet/EMODnetWFS/workflows/R-CMD-check/badge.svg)](https://github.com/EMODnet/EMODnetWFS/actions) -[![Codecov test coverage](https://codecov.io/gh/EMODnet/EMODnetWFS/branch/main/graph/badge.svg)](https://app.codecov.io/gh/EMODnet/EMODnetWFS?branch=main) +[![Codecov test coverage](https://codecov.io/gh/EMODnet/EMODnetWFS/branch/main/graph/badge.svg)](https://app.codecov.io/gh/EMODnet/EMODnetWFS/tree/main) -The goal of EMODnetWFS is to allow interrogation of and access to [EMODnet geographic vector data](https://emodnet.ec.europa.eu/en/emodnet-web-service-documentation#inline-nav-3) in R though the [EMODnet Web Feature Services](https://emodnet.ec.europa.eu/en/data). [Web Feature services (WFS)](https://www.ogc.org/standard/wfs/) represent a change in the way geographic information is created, modified and exchanged on the Internet and offer direct fine-grained access to geographic information at the feature and feature property level. +The goal of EMODnetWFS is to allow interrogation of and access to [EMODnet geographic vector data](https://emodnet.ec.europa.eu/en/emodnet-web-service-documentation#inline-nav-3) in R though the [EMODnet Web Feature Services](https://emodnet.ec.europa.eu/en/data). +[Web Feature services (WFS)](https://www.ogc.org/standard/wfs/) represent a change in the way geographic information is created, modified and exchanged on the Internet and offer direct fine-grained access to geographic information at the feature and feature property level. EMODnetWFS aims at offering an user-friendly interface to this rich data. ## Installation @@ -30,8 +31,8 @@ EMODnetWFS aims at offering an user-friendly interface to this rich data. You can install the development version of EMODnetWFS from GitHub with: ``` r -# install.packages("remotes") -remotes::install_github("EMODnet/EMODnetWFS") +# install.packages("pak") +pak::pak("EMODnet/EMODnetWFS") ``` ## Available services @@ -44,7 +45,7 @@ library(EMODnetWFS) knitr::kable(emodnet_wfs()) ``` -To explore available services in Rstudio use: +To explore available services you can use: ```r View(emodnet_wfs()) @@ -52,7 +53,7 @@ View(emodnet_wfs()) ## Create Service Client -Create new WFS Client. Specify the service using the `service` argument. +Specify the service using the `service` argument. ```{r} wfs_bio <- emodnet_init_wfs_client(service = "biology") diff --git a/README.md b/README.md index 325fa52e..e9d8c818 100644 --- a/README.md +++ b/README.md @@ -10,7 +10,7 @@ experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](h [![R build status](https://github.com/EMODnet/EMODnetWFS/workflows/R-CMD-check/badge.svg)](https://github.com/EMODnet/EMODnetWFS/actions) [![Codecov test -coverage](https://codecov.io/gh/EMODnet/EMODnetWFS/branch/main/graph/badge.svg)](https://app.codecov.io/gh/EMODnet/EMODnetWFS?branch=main) +coverage](https://codecov.io/gh/EMODnet/EMODnetWFS/branch/main/graph/badge.svg)](https://app.codecov.io/gh/EMODnet/EMODnetWFS/tree/main) The goal of EMODnetWFS is to allow interrogation of and access to @@ -29,8 +29,8 @@ an user-friendly interface to this rich data. You can install the development version of EMODnetWFS from GitHub with: ``` r -# install.packages("remotes") -remotes::install_github("EMODnet/EMODnetWFS") +# install.packages("pak") +pak::pak("EMODnet/EMODnetWFS") ``` ## Available services @@ -58,7 +58,7 @@ All available services are contained in the tibble returned by | seabed_habitats_general_datasets_and_products | | | seabed_habitats_individual_habitat_map_and_model_datasets | | -To explore available services in Rstudio use: +To explore available services you can use: ``` r View(emodnet_wfs()) @@ -66,7 +66,7 @@ View(emodnet_wfs()) ## Create Service Client -Create new WFS Client. Specify the service using the `service` argument. +Specify the service using the `service` argument. ``` r wfs_bio <- emodnet_init_wfs_client(service = "biology") @@ -140,7 +140,7 @@ emodnet_get_wfs_info(service = "biology") #> ✔ WFS client created successfully #> ℹ Service: "https://geo.vliz.be/geoserver/Emodnetbio/wfs" #> ℹ Version: "2.0.0" -#> # A tibble: 37 × 9 +#> # A tibble: 38 × 9 #> # Rowwise: #> data_source service_name service_url layer_name title abstract class format #> @@ -161,7 +161,7 @@ or you can pass a wfs client object. ``` r emodnet_get_wfs_info(wfs_bio) -#> # A tibble: 37 × 9 +#> # A tibble: 38 × 9 #> # Rowwise: #> data_source service_name service_url layer_name title abstract class format #> diff --git a/man/emodnet_get_layers.Rd b/man/emodnet_get_layers.Rd index 24a14fe2..1d5bbd80 100644 --- a/man/emodnet_get_layers.Rd +++ b/man/emodnet_get_layers.Rd @@ -16,14 +16,17 @@ emodnet_get_layers( ) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} -\item{layers}{a character vector of layer names. To get info on layers, including +\item{layers}{a character vector of layer names. To get info on layers, +including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} \item{crs}{integer. EPSG code for the output crs. If \code{NULL} (default), layers @@ -31,7 +34,8 @@ are returned with original crs.} \item{cql_filter}{character. Features returned can be filtered using valid Extended Common Query Language (ECQL) filtering statements -(\url{https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html}). Should be one of: +(\url{https://docs.geoserver.org/stable/en/user/filter/ecql_reference.html}). +Should be one of: \itemize{ \item{character string or character vector of length 1. Filter will be recycled across all layers requested} @@ -46,7 +50,8 @@ Layers without corresponding filters are returned whole } \item{reduce_layers}{whether to reduce output layers to a single \code{sf} object.} -\item{...}{additional vendor parameter arguments passed to \href{https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature}{\code{ows4R::GetFeature()}}. +\item{...}{additional vendor parameter arguments passed to +\href{https://docs.geoserver.org/stable/en/user/services/wfs/reference.html#getfeature}{\code{ows4R::GetFeature()}}.# nolint For example, including \code{count=1} returns the first available feature.} } \value{ diff --git a/man/emodnet_get_wfs_info.Rd b/man/emodnet_get_wfs_info.Rd index f9a7eebd..3d3b74b8 100644 --- a/man/emodnet_get_wfs_info.Rd +++ b/man/emodnet_get_wfs_info.Rd @@ -13,18 +13,22 @@ emodnet_get_wfs_info(wfs = NULL, service = NULL, service_version = NULL) emodnet_get_all_wfs_info() } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} -\item{layers}{a character vector of layer names. To get info on layers, including +\item{layers}{a character vector of layer names. To get info on layers, +including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} } \value{ -a tibble containing metadata on each layer available from the service. +a tibble containing metadata on each layer available from the +service. } \description{ Get WFS available layer information @@ -32,14 +36,17 @@ Get WFS available layer information \details{ To minimize the number of requests sent to webservices, these functions use \code{memoise} to cache results inside the active R session. -To clear the cache, re-start R or run \code{memoise::forget(emodnet_get_wfs_info)}/\code{memoise::forget(emodnet_get_layer_info)}. +To clear the cache, re-start R or +run \code{memoise::forget(emodnet_get_wfs_info)}/ +\code{memoise::forget(emodnet_get_layer_info)}. } \section{Functions}{ \itemize{ \item \code{emodnet_get_layer_info()}: Get metadata for specific layers. Requires a \code{wfs} object as input. -\item \code{emodnet_get_wfs_info()}: Get info on all layers from am EMODnet WFS service. +\item \code{emodnet_get_wfs_info()}: Get info on all layers from +an EMODnet WFS service. \item \code{emodnet_get_all_wfs_info()}: Get metadata on all layers and all available services from server. diff --git a/man/emodnet_init_wfs_client.Rd b/man/emodnet_init_wfs_client.Rd index 8d03ef32..b2c4696e 100644 --- a/man/emodnet_init_wfs_client.Rd +++ b/man/emodnet_init_wfs_client.Rd @@ -10,13 +10,16 @@ emodnet_init_wfs_client(service, service_version = NULL, logger = NULL) \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} -\item{logger}{the logger. Either \code{NULL} (no logging info), \code{"INFO"} (log about ows4R requests) +\item{logger}{the logger. Either \code{NULL} (no logging info), \code{"INFO"} +(log about ows4R requests) or \code{"DEBUG"} (including curl details).} } \value{ -An \code{\link[ows4R:WFSClient]{ows4R::WFSClient}} R6 object with methods for interfacing an OGC Web Feature Service. +An \code{\link[ows4R:WFSClient]{ows4R::WFSClient}} R6 object with methods for interfacing an +OGC Web Feature Service. } \description{ Initialise an EMODnet WFS client diff --git a/man/layer_attribute_descriptions.Rd b/man/layer_attribute_descriptions.Rd index a5b1ac77..866586fd 100644 --- a/man/layer_attribute_descriptions.Rd +++ b/man/layer_attribute_descriptions.Rd @@ -12,12 +12,14 @@ layer_attribute_descriptions( ) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} @@ -30,6 +32,9 @@ Get layer attribute description } \examples{ \dontrun{ -layer_attribute_descriptions(service = "human_activities", layer = "maritimebnds") +layer_attribute_descriptions( + service = "human_activities", + layer = "maritimebnds" +) } } diff --git a/man/layer_attribute_inspect.Rd b/man/layer_attribute_inspect.Rd index 38e1d810..b53b1834 100644 --- a/man/layer_attribute_inspect.Rd +++ b/man/layer_attribute_inspect.Rd @@ -13,12 +13,14 @@ layer_attribute_inspect( ) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} @@ -27,7 +29,8 @@ For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} \code{\link[=layer_attributes_get_names]{layer_attributes_get_names()}} to get layer attribute names.} } \value{ -Detailed summary of individual attribute (variable). Particularly useful for inspecting +Detailed summary of individual attribute (variable). Particularly +useful for inspecting factor or character variable levels or unique values. } \description{ diff --git a/man/layer_attributes_get_names.Rd b/man/layer_attributes_get_names.Rd index 14ba1f90..199c8258 100644 --- a/man/layer_attributes_get_names.Rd +++ b/man/layer_attributes_get_names.Rd @@ -12,12 +12,14 @@ layer_attributes_get_names( ) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} @@ -30,6 +32,9 @@ Get names of layer attributes } \examples{ \dontrun{ -layer_attributes_get_names(service = "human_activities", layer = "maritimebnds") +layer_attributes_get_names( + service = "human_activities", + layer = "maritimebnds" +) } } diff --git a/man/layer_attributes_summarise.Rd b/man/layer_attributes_summarise.Rd index 40ca5a6f..714a52e7 100644 --- a/man/layer_attributes_summarise.Rd +++ b/man/layer_attributes_summarise.Rd @@ -12,24 +12,30 @@ layer_attributes_summarise( ) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} } \value{ -output of \code{summary()} on the attributes (variables) in a given layer for a given service. +output of \code{summary()} on the attributes (variables) in a given layer +for a given service. } \description{ Get summaries of layer attributes (variables) } \examples{ \dontrun{ -layer_attributes_summarise(service = "human_activities", layer = "maritimebnds") +layer_attributes_summarise( + service = "human_activities", + layer = "maritimebnds" +) } } diff --git a/man/layer_attributes_tbl.Rd b/man/layer_attributes_tbl.Rd index 7ca61f9e..51d40de8 100644 --- a/man/layer_attributes_tbl.Rd +++ b/man/layer_attributes_tbl.Rd @@ -7,25 +7,30 @@ layer_attributes_tbl(wfs = NULL, service = NULL, service_version = NULL, layer) } \arguments{ -\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an OGC Web Feature Service.} +\item{wfs}{A \code{WFSClient} R6 object with methods for interfacing an +OGC Web Feature Service.} \item{service}{the EMODnet OGC WFS service name. For available services, see \code{\link[=emodnet_wfs]{emodnet_wfs()}}.} -\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} the WFS service version. Now always "2.0.0".} +\item{service_version}{\ifelse{html}{\href{https://lifecycle.r-lib.org/articles/stages.html#deprecated}{\figure{lifecycle-deprecated.svg}{options: alt='[Deprecated]'}}}{\strong{[Deprecated]}} +the WFS service version. Now always "2.0.0".} \item{layer}{character sting of layer name. To get info on layers, including \code{layer_name} use \code{\link[=emodnet_get_wfs_info]{emodnet_get_wfs_info()}}.} } \value{ -tibble of layer attribute (variable) values with geometry column removed. +tibble of layer attribute (variable) values +with geometry column removed. } \description{ Get layer attribute values tibble } \details{ -Request excluding spatial information can be significantly faster. Can be -useful for inspecting attribute values and constructing feature filters for more +Request excluding spatial information can be significantly faster. +Can be +useful for inspecting attribute values and constructing feature filters +for more targeted and faster layer download. } \examples{ diff --git a/pkgdown/_pkgdown.yml b/pkgdown/_pkgdown.yml index 75e0d174..21c50c3f 100644 --- a/pkgdown/_pkgdown.yml +++ b/pkgdown/_pkgdown.yml @@ -12,7 +12,7 @@ reference: - '`emodnet_wfs`' - '`emodnet_init_wfs_client`' - '`emodnet_get_wfs_info`' - + - title: Download layers, or information about layers contents: - '`emodnet_get_layers`' @@ -21,3 +21,17 @@ reference: - '`layer_attributes_get_names`' - '`layer_attributes_summarise`' - '`layer_attributes_tbl`' + +authors: + Anna Krystalli: + href: "https://www.r-rse.eu/" + Salvador Fernández-Bejarano: + href: "https://github.com/salvafern" + Thomas J Webb: + href: "https://www.sheffield.ac.uk/biosciences/people/academic-staff/tom-webb" + European Marine Observation Data Network (EMODnet) Biology project European Commission's Directorate - General for Maritime Affairs and Fisheries (DG MARE): + href: "https://emodnet.ec.europa.eu/en/biology" + VLIZ (VLAAMS INSTITUUT VOOR DE ZEE): + href: "https://www.vliz.be/" + Maëlle Salmon: + href: "https://masalmon.eu" diff --git a/tests/testthat/_snaps/deprecate-service-version.md b/tests/testthat/_snaps/deprecate-service-version.md index 770e4791..37f1b6a9 100644 --- a/tests/testthat/_snaps/deprecate-service-version.md +++ b/tests/testthat/_snaps/deprecate-service-version.md @@ -2,7 +2,8 @@ Code deprecate_message_service_version("1.1", "blop") - Warning + Condition + Warning: The `service_version` argument of `blop()` is deprecated as of EMODnetWFS 2.0.1. i All calls are made with service version 2.0.0. For more control, consider using {ows4r} directly. diff --git a/tests/testthat/_snaps/ui.md b/tests/testthat/_snaps/ui.md index 65d468d8..e789a721 100644 --- a/tests/testthat/_snaps/ui.md +++ b/tests/testthat/_snaps/ui.md @@ -2,20 +2,20 @@ Code cli_alert_success("hihihi") - Message + Message v hihihi # cli_alert_info() works Code cli_alert_info("hihihi") - Message + Message i hihihi # cli_alert_danger() works Code cli_alert_danger("hihihi") - Message + Message x hihihi diff --git a/tests/testthat/test-client.R b/tests/testthat/test-client.R index 342199b3..08b688e0 100644 --- a/tests/testthat/test-client.R +++ b/tests/testthat/test-client.R @@ -13,10 +13,15 @@ test_that("Services down handled", { skip_if_offline() webmockr::httr_mock() - test_url <- "https://demo.geo-solutions.it/geoserver/ows?request=GetCapabilities" + test_url <- "https://demo.geo-solutions.it/geoserver/ows?request=GetCapabilities" # nolint webmockr::stub_request("get", uri = test_url) %>% - webmockr::wi_th(headers = list("Accept" = "application/json, text/xml, application/xml, */*")) %>% + webmockr::wi_th( + headers = + list( + "Accept" = "application/json, text/xml, application/xml, */*" + ) + ) %>% webmockr::to_return(status = 500) %>% webmockr::to_return(status = 200) diff --git a/tests/testthat/test-info.R b/tests/testthat/test-info.R index 86ddc6fa..8fef5107 100644 --- a/tests/testthat/test-info.R +++ b/tests/testthat/test-info.R @@ -18,7 +18,7 @@ test_that("wfs info works on wfs object", { expect_s3_class(layer_info_all, class = c("tbl_df", "tbl", "data.frame")) expect_gt(nrow(layer_info_all), 0L) expect_identical(unique(layer_info_all$service_name), "biology") - expect_identical(unique(layer_info_all$service_url), "https://geo.vliz.be/geoserver/Emodnetbio/wfs") + expect_identical(unique(layer_info_all$service_url), "https://geo.vliz.be/geoserver/Emodnetbio/wfs") # nolint }) test_that("emodnet_get_layer_info works", { diff --git a/tests/testthat/test-layer_attributes.R b/tests/testthat/test-layer_attributes.R index 5f84fcaa..a4efc13f 100644 --- a/tests/testthat/test-layer_attributes.R +++ b/tests/testthat/test-layer_attributes.R @@ -3,12 +3,40 @@ test_that("layer attributes stuff works", { wfs <- create_biology_wfs() with_mock_dir("biology-layers", { layer_attr <- layer_attributes_get_names(wfs, layer = "mediseh_zostera_m_pnt") - layer_attr_desc <- layer_attribute_descriptions(wfs, layer = "mediseh_zostera_m_pnt") - country <- layer_attribute_inspect(wfs, layer = "mediseh_zostera_m_pnt", attribute = "country") - id <- layer_attribute_inspect(wfs, layer = "mediseh_zostera_m_pnt", attribute = "id") - attr_summary <- layer_attributes_summarise(wfs, layer = "mediseh_zostera_m_pnt") - crs1 <- get_layer_default_crs(layer = "mediseh_zostera_m_pnt", wfs, output = "epsg.text") - crs2 <- get_layer_default_crs(layer = "mediseh_zostera_m_pnt", wfs, output = "epsg.num") + + layer_attr_desc <- layer_attribute_descriptions( + wfs, + layer = "mediseh_zostera_m_pnt" + ) + + country <- layer_attribute_inspect( + wfs, + layer = "mediseh_zostera_m_pnt", + attribute = "country" + ) + + id <- layer_attribute_inspect( + wfs, + layer = "mediseh_zostera_m_pnt", + attribute = "id" + ) + + attr_summary <- layer_attributes_summarise( + wfs, + layer = "mediseh_zostera_m_pnt" + ) + + crs1 <- get_layer_default_crs( + layer = "mediseh_zostera_m_pnt", + wfs, + output = "epsg.text" + ) + + crs2 <- get_layer_default_crs( + layer = "mediseh_zostera_m_pnt", + wfs, + output = "epsg.num" + ) }) expect_identical(layer_attr, c("id", "country", "the_geom")) expect_snapshot_output(layer_attr_desc) diff --git a/tests/testthat/test-layers.R b/tests/testthat/test-layers.R index a19fb04c..6722e597 100644 --- a/tests/testthat/test-layers.R +++ b/tests/testthat/test-layers.R @@ -112,8 +112,17 @@ test_that("reduce works", { test_that("works when data.frame layer", { skip_if_offline() wfs <- create_biology_wfs() - expect_snapshot_error(emodnet_get_layers(wfs, layers = c("OOPS_summaries", "OOPS_metadata"), reduce_layers = TRUE)) - result_list <- emodnet_get_layers(wfs, layers = c("OOPS_summaries", "OOPS_metadata")) + expect_snapshot_error( + emodnet_get_layers( + wfs, + layers = c("OOPS_summaries", "OOPS_metadata"), + reduce_layers = TRUE + ) + ) + result_list <- emodnet_get_layers( + wfs, + layers = c("OOPS_summaries", "OOPS_metadata") + ) expect_type(result_list, "list") expect_s3_class(result_list[[1]], "data.frame") expect_s3_class(result_list[[2]], "data.frame") diff --git a/tests/testthat/test-ui.R b/tests/testthat/test-ui.R index 69318be6..25c2e3c6 100644 --- a/tests/testthat/test-ui.R +++ b/tests/testthat/test-ui.R @@ -18,4 +18,3 @@ test_that("cli_alert_danger() works", { withr::local_options(EMODnetWFS.quiet = FALSE) expect_snapshot(cli_alert_danger("hihihi")) }) - diff --git a/tests/testthat/testdata/test-data-prep.R b/tests/testthat/testdata/test-data-prep.R index 96c07535..d21d905e 100644 --- a/tests/testthat/testdata/test-data-prep.R +++ b/tests/testthat/testdata/test-data-prep.R @@ -4,5 +4,9 @@ attr_desc <- layer_attribute_descriptions(wfs, layer = "maritimebnds") testthis::use_testdata(attr_desc, overwrite = TRUE) -maritime_crs <- EMODnetWFS:::get_layer_default_crs(layer = "maritimebnds", wfs, output = "crs") +maritime_crs <- EMODnetWFS:::get_layer_default_crs( + layer = "maritimebnds", + wfs, + output = "crs" +) testthis::use_testdata(maritime_crs, overwrite = TRUE) diff --git a/vignettes/figure/unnamed-chunk-6-1.png b/vignettes/EMODnetWFS-unnamed-chunk-6-1.png similarity index 100% rename from vignettes/figure/unnamed-chunk-6-1.png rename to vignettes/EMODnetWFS-unnamed-chunk-6-1.png diff --git a/vignettes/figure/unnamed-chunk-9-1.png b/vignettes/EMODnetWFS-unnamed-chunk-9-1.png similarity index 100% rename from vignettes/figure/unnamed-chunk-9-1.png rename to vignettes/EMODnetWFS-unnamed-chunk-9-1.png diff --git a/vignettes/EMODnetWFS.Rmd b/vignettes/EMODnetWFS.Rmd index 858cbfc2..9cccd8f1 100644 --- a/vignettes/EMODnetWFS.Rmd +++ b/vignettes/EMODnetWFS.Rmd @@ -1,5 +1,10 @@ --- title: "EMODnetWFS Case Study: Accessing and mapping EMODnet data" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{API details} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} --- @@ -96,19 +101,20 @@ seabed_wfs_client <- emodnet_init_wfs_client(service = "seabed_habitats_general_ emodnet_get_wfs_info(wfs = seabed_wfs_client) #> # A tibble: 36 × 9 #> # Rowwise: -#> data_source service_name service_url layer_name title abstract class format layer_namespace -#> -#> 1 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 2 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 3 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 4 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 5 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 6 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 7 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 8 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 9 emodnet_wfs seabed_habitats_ge… https://ow… art17_hab… 2018… "Gridde… WFSF… sf emodnet_open -#> 10 emodnet_wfs seabed_habitats_ge… https://ow… biogenic_… Biog… "This l… WFSF… sf emodnet_open +#> data_source service_name service_url layer_name title abstract class +#> +#> 1 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 2 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 3 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 4 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 5 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 6 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 7 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 8 emodnet_wfs seabed_habita… https://ow… art17_hab… 2013… "Gridde… WFSF… +#> 9 emodnet_wfs seabed_habita… https://ow… art17_hab… 2018… "Gridde… WFSF… +#> 10 emodnet_wfs seabed_habita… https://ow… biogenic_… Biog… "This l… WFSF… #> # ℹ 26 more rows +#> # ℹ 2 more variables: format , layer_namespace ``` @@ -125,11 +131,12 @@ emodnet_get_layer_info( ) #> # A tibble: 3 × 9 #> # Rowwise: -#> data_source service_name service_url layer_name title abstract class format layer_namespace -#> -#> 1 emodnet_wfs https://ows.emodnet… seabed_hab… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 2 emodnet_wfs https://ows.emodnet… seabed_hab… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open -#> 3 emodnet_wfs https://ows.emodnet… seabed_hab… art17_hab… 2013… "Gridde… WFSF… sf emodnet_open +#> data_source service_name service_url layer_name title abstract class +#> +#> 1 emodnet_wfs https://ows.em… seabed_hab… art17_hab… 2013… "Gridde… WFSF… +#> 2 emodnet_wfs https://ows.em… seabed_hab… art17_hab… 2013… "Gridde… WFSF… +#> 3 emodnet_wfs https://ows.em… seabed_hab… art17_hab… 2013… "Gridde… WFSF… +#> # ℹ 2 more variables: format , layer_namespace ``` @@ -150,15 +157,15 @@ class(habitats_directive_layers) glimpse(habitats_directive_layers) #> Rows: 221 #> Columns: 9 -#> $ gml_id "art17_hab_1110.13", "art17_hab_1110.22", "art17_hab_1110.25", "art17_h… -#> $ habitat_code "1110", "1110", "1110", "1110", "1110", "1110", "1110", "1110", "1110",… -#> $ ms "DK", "ES", "ES", "PT", "PT", "PL", "DK", "FR", "UK", "BE", "BE", "GR",… -#> $ region "ATL", "MAC", "MMAC", "MMAC", "MATL", "MBAL", "MBAL", "MATL", "MATL", "… -#> $ cs_ms "U2+", "U1+", "U1+", "XX", "U1-", "U1-", "U1-", "U1x", "U1x", "U1x", "U… -#> $ country_code "Denmark", "Spain", "Spain", "Portugal", "Portugal", "Poland", "Denmark… -#> $ habitat_code_uri "http://dd.eionet.europa.eu/vocabulary/art17_2018/habitats/1110", "http… -#> $ habitat_description "Sandbanks which are slightly covered by sea water all the time", "Sand… -#> $ geom MULTISURFACE (POLYGON ((420..., MULTISURFACE (POLYGON ((19… +#> $ gml_id "art17_hab_1110.13", "art17_hab_1110.22", "… +#> $ habitat_code "1110", "1110", "1110", "1110", "1110", "11… +#> $ ms "DK", "ES", "ES", "PT", "PT", "PL", "DK", "… +#> $ region "ATL", "MAC", "MMAC", "MMAC", "MATL", "MBAL… +#> $ cs_ms "U2+", "U1+", "U1+", "XX", "U1-", "U1-", "U… +#> $ country_code "Denmark", "Spain", "Spain", "Portugal", "P… +#> $ habitat_code_uri "http://dd.eionet.europa.eu/vocabulary/art1… +#> $ habitat_description "Sandbanks which are slightly covered by se… +#> $ geom MULTISURFACE (POLYGON ((420...… ``` @@ -179,7 +186,7 @@ map <- mapview(habitats_directive_layers, zcol = "habitat_description", burst = map ``` -![plot of chunk unnamed-chunk-6](figure/unnamed-chunk-6-1.png) +![plot of chunk unnamed-chunk-6](EMODnetWFS-unnamed-chunk-6-1.png) Furthermore, we can get data from other EMODnet lots and combine them. The Human Activities portal provides the maritime boundaries of the European Union state members. This time we will not initiate a WFS client, but we will use the service name. The WFS client will be generated on the fly. @@ -189,24 +196,22 @@ Same as before, we have a look at the layers available first. ```r emodnet_get_wfs_info(service = "human_activities") -#> ✔ WFS client created successfully -#> ℹ Service: "https://ows.emodnet-humanactivities.eu/wfs" -#> ℹ Version: "2.0.0" #> # A tibble: 99 × 9 #> # Rowwise: -#> data_source service_name service_url layer_name title abstract class format layer_namespace -#> -#> 1 emodnet_wfs human_activities https://ows.e… activelic… Acti… The dat… WFSF… sf emodnet -#> 2 emodnet_wfs human_activities https://ows.e… advisoryc… Advi… This sh… WFSF… sf emodnet -#> 3 emodnet_wfs human_activities https://ows.e… aquacultu… Advi… This sh… WFSF… sf emodnet -#> 4 emodnet_wfs human_activities https://ows.e… baltic Advi… This sh… WFSF… sf emodnet -#> 5 emodnet_wfs human_activities https://ows.e… blacksea Advi… This sh… WFSF… sf emodnet -#> 6 emodnet_wfs human_activities https://ows.e… longdista… Advi… This sh… WFSF… sf emodnet -#> 7 emodnet_wfs human_activities https://ows.e… market Advi… This sh… WFSF… sf emodnet -#> 8 emodnet_wfs human_activities https://ows.e… mediterra… Advi… This sh… WFSF… sf emodnet -#> 9 emodnet_wfs human_activities https://ows.e… northsea Advi… This sh… WFSF… sf emodnet -#> 10 emodnet_wfs human_activities https://ows.e… northwest… Advi… This sh… WFSF… sf emodnet +#> data_source service_name service_url layer_name title abstract class +#> +#> 1 emodnet_wfs human_activit… https://ow… activelic… Acti… The dat… WFSF… +#> 2 emodnet_wfs human_activit… https://ow… advisoryc… Advi… This sh… WFSF… +#> 3 emodnet_wfs human_activit… https://ow… aquacultu… Advi… This sh… WFSF… +#> 4 emodnet_wfs human_activit… https://ow… baltic Advi… This sh… WFSF… +#> 5 emodnet_wfs human_activit… https://ow… blacksea Advi… This sh… WFSF… +#> 6 emodnet_wfs human_activit… https://ow… longdista… Advi… This sh… WFSF… +#> 7 emodnet_wfs human_activit… https://ow… market Advi… This sh… WFSF… +#> 8 emodnet_wfs human_activit… https://ow… mediterra… Advi… This sh… WFSF… +#> 9 emodnet_wfs human_activit… https://ow… northsea Advi… This sh… WFSF… +#> 10 emodnet_wfs human_activit… https://ow… northwest… Advi… This sh… WFSF… #> # ℹ 89 more rows +#> # ℹ 2 more variables: format , layer_namespace ``` The `layer_name` for the [maritime boundaries](https://www.eea.europa.eu/data-and-maps/data/maritime-boundaries) seems to be `maritimebnds`. This dataset was developed based on the official [data provided by the European Environmental Agency](https://www.eea.europa.eu/data-and-maps/data/maritime-boundaries) and the [Maritime Boundaries Database](https://marineregions.org/eez.php) compiled by MarineRegions.org (Flanders Marine Institute, 2019). @@ -228,19 +233,19 @@ maritime_boundaries <- emodnet_get_layers( glimpse(maritime_boundaries) #> Rows: 64 #> Columns: 13 -#> $ gml_id "maritimebnds.54", "maritimebnds.55", "maritimebnds.56", "maritimebnds.57", "mar… -#> $ objectid 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 39, 40, 41, 42, 44, 45, … -#> $ mblszotpid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,… -#> $ localid 49036, 49042, 49063, 49064, 49065, 49066, 49087, 49099, 49101, 49102, 49104, 491… -#> $ sitename "Territory sea (12 nm)", "Territory sea (12 nm)", "Territory sea (12 nm)", "Terr… -#> $ legalfound NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,… -#> $ legalfou_1 NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, … -#> $ country "United Kingdom", "France", "France", "France", "France", "France", "Spain", "Cy… -#> $ nationalle NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, … -#> $ nutscode "UK", "FR", "FR", "FR", "FR", "FR", "ES", "CY", "UK", "UK", "UK", "FR", "FR", "F… -#> $ mblsds_mbl "In www.marineregions.org", "In www.marineregions.org", "In www.marineregions.or… -#> $ shape_leng 141.545470, 70.017156, 5.116398, 1.949563, 2.072975, 1.837879, 27.878496, 13.642… -#> $ the_geom MULTICURVE (LINESTRING (-13..., MULTICURVE (LINESTRING (169..., MULTI… +#> $ gml_id "maritimebnds.54", "maritimebnds.55", "maritimebnds.… +#> $ objectid 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, … +#> $ mblszotpid 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1… +#> $ localid 49036, 49042, 49063, 49064, 49065, 49066, 49087, 490… +#> $ sitename "Territory sea (12 nm)", "Territory sea (12 nm)", "T… +#> $ legalfound NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA,… +#> $ legalfou_1 NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, … +#> $ country "United Kingdom", "France", "France", "France", "Fra… +#> $ nationalle NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, NA, … +#> $ nutscode "UK", "FR", "FR", "FR", "FR", "FR", "ES", "CY", "UK"… +#> $ mblsds_mbl "In www.marineregions.org", "In www.marineregions.or… +#> $ shape_leng 141.545470, 70.017156, 5.116398, 1.949563, 2.072975,… +#> $ the_geom MULTICURVE (LINESTRING (-13..., MULTICURV… ``` @@ -258,7 +263,7 @@ maritime_boundaries <- maritime_boundaries %>% map + mapview(maritime_boundaries) ``` -![plot of chunk unnamed-chunk-9](figure/unnamed-chunk-9-1.png) +![plot of chunk unnamed-chunk-9](EMODnetWFS-unnamed-chunk-9-1.png) We have now combined data from the Seabed Habitats and Human Activities portals. However, there is more! EMODnet provides also physics, chemistry, biological or bathymetry data. Explore all the layers available with. diff --git a/vignettes/EMODnetWFS.Rmd.orig b/vignettes/EMODnetWFS.Rmd.orig index 907a1419..815a2c34 100644 --- a/vignettes/EMODnetWFS.Rmd.orig +++ b/vignettes/EMODnetWFS.Rmd.orig @@ -1,12 +1,18 @@ --- title: "EMODnetWFS Case Study: Accessing and mapping EMODnet data" +output: rmarkdown::html_vignette +vignette: > + %\VignetteIndexEntry{API details} + %\VignetteEngine{knitr::rmarkdown} + %\VignetteEncoding{UTF-8} --- ```{r, include = FALSE} knitr::opts_chunk$set( - collapse = TRUE, - comment = "#>", - echo = TRUE, eval = TRUE, warning = FALSE + collapse = TRUE, + comment = "#>", + echo = TRUE, eval = TRUE, warning = FALSE, + fig.path = "EMODnetWFS-" ) ``` diff --git a/vignettes/articles/ecql_filtering.Rmd b/vignettes/articles/ecql_filtering.Rmd index 8d388314..ecb27659 100644 --- a/vignettes/articles/ecql_filtering.Rmd +++ b/vignettes/articles/ecql_filtering.Rmd @@ -107,7 +107,11 @@ You can also inspect individual attributes which, in the case of categorical var ```{r} -layer_attribute_inspect(wfs, layer = "mediseh_zostera_m_pnt", attribute = "country") +layer_attribute_inspect( + wfs, + layer = "mediseh_zostera_m_pnt", + attribute = "country" +) ``` @@ -209,9 +213,16 @@ This time we'll use the **mediseh_posidonia_nodata**. We can inspect again, using some of our interrogative functions to get information on layer attributes. ```{r} -layer_attributes_get_names(wfs, layer = "mediseh_posidonia_nodata") +layer_attributes_get_names( + wfs, + layer = "mediseh_posidonia_nodata" +) -layer_attribute_inspect(wfs, layer = "mediseh_posidonia_nodata", attribute = "km") +layer_attribute_inspect( + wfs, + layer = "mediseh_posidonia_nodata", + attribute = "km" +) ``` We can see that values range between `0.23` and `~473` with a mean of `~40`.