From 55df98773c7834b6c41537e9a54847dddc0428e9 Mon Sep 17 00:00:00 2001 From: hurielreichel Date: Wed, 22 Feb 2023 14:22:19 +0100 Subject: [PATCH] #4 filter has now year and month as args --- DESCRIPTION | 4 +- R/datacube.R | 2 +- R/filter.R | 184 +++++++++++++++++++++++++++++++- R/group_by.R | 2 +- R/mutate.R | 2 +- R/rename.R | 2 +- R/resample.R | 2 +- R/select.R | 2 +- R/slice.R | 2 +- R/summarise.R | 2 +- R/summarize.R | 2 +- man/datacube.Rd | 2 +- man/filter.Rd | 23 +++- man/group_by.Rd | 2 +- man/mutate.Rd | 2 +- man/rename.Rd | 2 +- man/resample.Rd | 2 +- man/select.Rd | 2 +- man/slice.Rd | 2 +- man/summarise.Rd | 2 +- man/summarize.Rd | 2 +- tests/testthat/test-filter.R | 15 ++- tests/testthat/test-group_by.R | 1 + tests/testthat/test-mutate.R | 1 + tests/testthat/test-rename.R | 1 + tests/testthat/test-resample.R | 1 + tests/testthat/test-select.R | 1 + tests/testthat/test-slice.R | 1 + tests/testthat/test-summarise.R | 1 + tests/testthat/test-summarize.R | 1 + 30 files changed, 241 insertions(+), 29 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 40578f0..5e536b9 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: tidyopeneo Type: Package -Title: tidyopeneo : Wrap dplyr functions for openEO datacubes (OpenEOWrap) +Title: tidyopeneo : Wrap dplyr functions for openEO datacubes (tidyopeneo) Version: 0.1.0 Author: Huriel Reichel Maintainer: The package maintainer @@ -13,7 +13,7 @@ Encoding: UTF-8 LazyData: true Depends: R (>= 3.3.3), dplyr, openeo, cli, rjson Imports: sf, methods -RoxygenNote: 7.2.1 +RoxygenNote: 7.2.3 Suggests: knitr, rmarkdown, diff --git a/R/datacube.R b/R/datacube.R index 068c39b..a3e05a9 100644 --- a/R/datacube.R +++ b/R/datacube.R @@ -4,7 +4,7 @@ #' openeo::processes()$load_collection() (https://processes.openeo.org/#load_collection). #' This is understood as the **starting point** when working with tidyopeneo. (optional) #' @param data ProcessNode datacube from openeo (optional) -#' @param .con (optional) character link to openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) character link to openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import openeo diff --git a/R/filter.R b/R/filter.R index 486014b..2149f59 100644 --- a/R/filter.R +++ b/R/filter.R @@ -20,6 +20,10 @@ #' never both. #' For **filter_bbox**, the bounding box, which may include a vertical axis #' (see `base` and `height`). +#' @param .year integer or list of integers stating the years you want to filter on the +#' datacube. +#' @param .month integer or list of integers referring to the months you want to filter +#' on the datacube. #' @param .dimension (optional) For **filter_temporal** : The name of the temporal dimension #' to filter on. If no specific dimension is specified or it is set to `null`, #' the filter applies to all temporal dimensions. Fails with a `DimensionNotAvailable` @@ -28,7 +32,7 @@ #' filtering, specified as GeoJSON. #' @param .context (optional) : any Additional data to be passed to the condition. #' Mandatory for filter_labels or array_filter processes. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli @@ -39,10 +43,17 @@ #' library(sf) #' #' con = connect(host = "https://openeo.cloud") -#' dc = datacube(id = "SENTINEL_5P_L2") +#' dc = datacube(id = "SENTINEL1_GRD") +#' +#' # filter_temporal +#' dc_y = dc %>% filter(.year = c(2020, 2021, 2022)) +#' +#' dc_m = dc %>% filter(.month = c(6,7,8)) +#' +#' dc_ym = dc %>% filter(.year = c(2020, 2021, 2022), .month = c(6,7,8)) #' #' # filter_temporal and filter_bbox -#' dc = dc %>% +#' dc2 = dc %>% #' filter(.extent = c("2021-01-01", "2021-03-03")) %>% #' filter(.extent = c(west = 6.09, east = 6.99, south = 46.15, north = 46.57)) #' @@ -55,7 +66,7 @@ #' st_bbox() %>% #' st_as_sfc() #' -#' dc = dc %>% filter(.geometries = pol) +#' dc = dc2 %>% filter(.geometries = pol) #' #' # array_filter #' # ToDO... @@ -65,6 +76,7 @@ filter.datacube <- function(.data = NULL, ..., .condition = NULL, .dimension = NULL, .context = NULL, .extent = NULL, .geometries = NULL, + .year = NULL, .month = NULL, .p = openeo::processes(.con), .con = NULL) { #check dots ... @@ -89,6 +101,170 @@ filter.datacube <- function(.data = NULL, ..., dc = .p$filter_temporal(data = .data, extent = .extent, dimension = .dimension) cli::cli_alert_success("filter_temporal applied") + ## Working with years + } else if (!is.null(.year) & is.null(.month) & is.null(.geometries) & is.null(.condition)& + is.null(.context)){ + + ### Extract starting year of collection + process_json = .p$save_result(data = .data, format = list_file_formats()$output$JSON) %>% + as("Process") %>% openeo::toJSON() %>% rjson::fromJSON() %>% suppressWarnings() + id = process_json$process_graph[[1]]$arguments$id + + collections = list_collections() %>% suppressWarnings() + native_time_ext = c(collections[[id]]$extent$temporal[[1]][[1]] %>% as.Date() %>% format("%04Y-%m-%d"), + collections[[id]]$extent$temporal[[1]][[2]]) + native_time_ext = ifelse(is.na(native_time_ext), Sys.Date() %>% format("%04Y-%m-%d"), native_time_ext) + + ### stop if year outside of range + if (min(.year) < native_time_ext[1] %>% substr(1,4) | max(.year) > native_time_ext[2] %>% substr(1,4)){ + stop( + cli::cli_alert_danger("You're trying to filter outside of the range of the collection {native_time_ext}") + ) + } + + ### Iterate through the called years + dcs = list() + for (i in 1:length(.year)){ + dcs[[i]] <- .p$filter_temporal( + data = .data, + extent = c(paste(.year[i], "01-01", sep = "-"), paste(.year[i], "12-31", sep = "-")), + dimension = .dimension) + } + + ### merge generated data cubes + if (length(dcs) > 1){ + for (i in 1:length(dcs)){ + if (i == 1){i = i+1} + else if (i == 2){ + dc = .p$merge_cubes(dcs[[i]], dcs[[i-1]]) + } else { + dc = .p$merge_cubes(dc, dcs[[i]]) + } + } + cli::cli_alert_success("merge_cubes applied") + + ### Do not merge --- simple filter for a single year + } else { + dc = .p$filter_temporal( + data = .data, + c(paste(.year, "01-01", sep = "-"), paste(.year, "12-31", sep = "-")), + dimension = .dimension) + cli::cli_alert_success("filter_temporal applied") + } + + ## Working with Months + } else if (is.null(.year) & !is.null(.month) & is.null(.geometries) & is.null(.condition)& + is.null(.context)){ + + ### Extract time extent of collection + process_json = .p$save_result(data = .data, format = list_file_formats()$output$JSON) %>% + as("Process") %>% openeo::toJSON() %>% rjson::fromJSON() %>% suppressWarnings() + id = process_json$process_graph[[1]]$arguments$id + + collections = list_collections() %>% suppressWarnings() + native_time_ext = c(collections[[id]]$extent$temporal[[1]][[1]] %>% as.Date() %>% format("%04Y-%m-%d"), + collections[[id]]$extent$temporal[[1]][[2]]) + native_time_ext = ifelse(is.na(native_time_ext), Sys.Date() %>% format("%04Y-%m-%d"), native_time_ext) + + ### Iterate through the existing years and called months + years = seq(native_time_ext[1] %>% substr(1, 4), native_time_ext[2] %>% substr(1, 4), 1) + months = ifelse(.month < 10, paste0("0", .month), .month) %>% as.character() + next_months = ifelse((.month + 1) == 13, 1, .month) + next_months = ifelse(next_months < 10, paste0("0", next_months), next_months) %>% as.character() + dcs = list() + for (y in 1:length(years)){ + for (m in 1:length(months)){ + date1 = paste(years[y], months[m], "01", sep = "-") + date2 = paste(years[y], next_months[m], "01", sep = "-") + date2 = as.Date(date2) - 1 + date2 = date2 %>% format("%04Y-%m-%d") + + if (date1 < native_time_ext[1] | date2 > native_time_ext[2]){ + next + } + + dcs <- append(dcs, .p$filter_temporal( + data = .data, extent = c(date1, date2, dimension = .dimension))) + } + } + cli::cli_alert_success("filter_temporal applied") + + ### merge generated data cubes + for (i in 1:length(dcs)){ + if (i == 1){i = i+1} + else if (i == 2){ + dc = .p$merge_cubes(dcs[[i]], dcs[[i-1]]) + } else { + dc = .p$merge_cubes(dc, dcs[[i]]) + } + } + cli::cli_alert_success("merge_cubes applied") + + ## Working with Months and Years + } else if (!is.null(.year) & !is.null(.month) & is.null(.geometries) & is.null(.condition)& + is.null(.context)){ + + ### Extract time extent of collection + process_json = .p$save_result(data = .data, format = list_file_formats()$output$JSON) %>% + as("Process") %>% openeo::toJSON() %>% rjson::fromJSON() %>% suppressWarnings() + id = process_json$process_graph[[1]]$arguments$id + + collections = list_collections() %>% suppressWarnings() + native_time_ext = c(collections[[id]]$extent$temporal[[1]][[1]] %>% as.Date() %>% format("%04Y-%m-%d"), + collections[[id]]$extent$temporal[[1]][[2]]) + native_time_ext = ifelse(is.na(native_time_ext), Sys.Date() %>% format("%04Y-%m-%d"), native_time_ext) + + ### stop if year outside of range + if (min(.year) < native_time_ext[1] %>% substr(1,4) | max(.year) > native_time_ext[2] %>% substr(1,4)){ + stop( + cli::cli_alert_danger("You're trying to filter outside of the range of the collection {native_time_ext}") + ) + } + + ### Iterate through the existing years and called months + years = .year + months = ifelse(.month < 10, paste0("0", .month), .month) %>% as.character() + next_months = ifelse((.month + 1) == 13, 1, .month) + next_months = ifelse(next_months < 10, paste0("0", next_months), next_months) %>% as.character() + dcs = list() + for (y in 1:length(years)){ + for (m in 1:length(months)){ + date1 = paste(years[y], months[m], "01", sep = "-") + date2 = paste(years[y], next_months[m], "01", sep = "-") + date2 = as.Date(date2) - 1 + date2 = date2 %>% format(., "%04Y-%m-%d") + + if (date1 < native_time_ext[1] | date2 > native_time_ext[2]){ + next + } + + dcs <- append(dcs, .p$filter_temporal( + data = .data, extent = c(date1, date2, dimension = .dimension))) + } + } + cli::cli_alert_success("filter_temporal applied") + + ### merge generated data cubes + if (length(dcs) > 1){ + for (i in 1:length(dcs)){ + if (i == 1){i = i+1} + else if (i == 2){ + dc = .p$merge_cubes(dcs[[i]], dcs[[i-1]]) + } else { + dc = .p$merge_cubes(dc, dcs[[i]]) + } + } + cli::cli_alert_success("merge_cubes applied") + + ### Do not merge --- simple filter for a single year + } else { + dc = .p$filter_temporal( + data = .data, + c(paste(.year, "01-01", sep = "-"), paste(.year, "12-31", sep = "-")), + dimension = .dimension) + cli::cli_alert_success("filter_temporal applied") + } + #filter_bbox } else if (length(.extent == 4) & is.null(.geometries) & is.null(.condition)& is.null(.context)) { diff --git a/R/group_by.R b/R/group_by.R index d6029ef..dc7041c 100644 --- a/R/group_by.R +++ b/R/group_by.R @@ -71,7 +71,7 @@ #' and/or times. Is only required to be specified if the values for the start of #' the temporal intervals are not distinct and thus the default labels would not #' be unique. The number of labels and the number of groups need to be equal. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli sf diff --git a/R/mutate.R b/R/mutate.R index ddc4d0a..178edac 100644 --- a/R/mutate.R +++ b/R/mutate.R @@ -57,7 +57,7 @@ #' after, so an overlap of 8 pixels will add 8 pixels on both sides of the window, #' so 16 in total.Be aware that large overlaps increase the need for computational #' resources and modifying overlapping data in subsequent operations have no effect. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/R/rename.R b/R/rename.R index 94170f5..7ae3d72 100644 --- a/R/rename.R +++ b/R/rename.R @@ -9,7 +9,7 @@ #' `DimensionNotAvailable` exception if the specified dimension does not exist. #' @param .target A new Name for the dimension. Fails with a `DimensionExists` #' exception if a dimension with the specified name exists. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/R/resample.R b/R/resample.R index 02ce3fe..af0bb4d 100644 --- a/R/resample.R +++ b/R/resample.R @@ -53,7 +53,7 @@ #' to no-data (`null`). #' @param .target_process (optional) either "spatial" to apply **resample_cube_spatial** or #' "temporal" to apply **resample_cube_temporal**. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @details if arg .target is not defined, resample_spatial is gonna be run. diff --git a/R/select.R b/R/select.R index 42b6c89..8ff565d 100644 --- a/R/select.R +++ b/R/select.R @@ -18,7 +18,7 @@ #' specified in micrometers. The order of the specified array defines the #' order of the bands in the data cube. If multiple bands match the wavelengths, #' all matched bands are included in the original order. -#' @param .con openeo connection. Default to "https://openeo.cloud" +#' @param .con openeo connection. Default to NULL #' @param .p processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/R/slice.R b/R/slice.R index db210d1..3d38b8f 100644 --- a/R/slice.R +++ b/R/slice.R @@ -20,7 +20,7 @@ #' If n is greater than the number of days available in the collection or datacube (or prop > 1), the result #' will be truncated to the group size. If the proportion of a group size does not yield an integer number of #'rows, the absolute value of prop * ndays(.data) is rounded down. -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/R/summarise.R b/R/summarise.R index 9d2f0c0..f4a1fdb 100644 --- a/R/summarise.R +++ b/R/summarise.R @@ -12,7 +12,7 @@ #' @param .dimension The name of the dimension over which to reduce. Fails with #' a `DimensionNotAvailable` exception if the specified dimension does not exist. #' @param .context (optional) Additional data to be passed to the reducer (optional). -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/R/summarize.R b/R/summarize.R index c1edc34..eaf6e90 100644 --- a/R/summarize.R +++ b/R/summarize.R @@ -12,7 +12,7 @@ #' @param .dimension The name of the dimension over which to reduce. Fails with #' a `DimensionNotAvailable` exception if the specified dimension does not exist. #' @param .context (optional) Additional data to be passed to the reducer (optional). -#' @param .con (optional) openeo connection. Default to "https://openeo.cloud" +#' @param .con (optional) openeo connection. Default to NULL #' @param .p (optional) processes available at .con #' @return datacube #' @import dplyr openeo cli diff --git a/man/datacube.Rd b/man/datacube.Rd index f57b173..3d6500c 100644 --- a/man/datacube.Rd +++ b/man/datacube.Rd @@ -15,7 +15,7 @@ This is understood as the **starting point** when working with tidyopeneo. (opti \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) character link to openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) character link to openeo connection. Default to NULL} } \value{ datacube diff --git a/man/filter.Rd b/man/filter.Rd index 9fd0dc9..29deb34 100644 --- a/man/filter.Rd +++ b/man/filter.Rd @@ -13,6 +13,8 @@ .context = NULL, .extent = NULL, .geometries = NULL, + .year = NULL, + .month = NULL, .p = openeo::processes(.con), .con = NULL ) @@ -49,9 +51,15 @@ For **filter_bbox**, the bounding box, which may include a vertical axis \item{.geometries}{(optional) For **filter_spatial** : one or more geometries used for filtering, specified as GeoJSON.} +\item{.year}{integer or list of integers stating the years you want to filter on the +datacube.} + +\item{.month}{integer or list of integers referring to the months you want to filter +on the datacube.} + \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube @@ -65,10 +73,17 @@ library(tidyopeneo) library(sf) con = connect(host = "https://openeo.cloud") -dc = datacube(id = "SENTINEL_5P_L2") +dc = datacube(id = "SENTINEL1_GRD") + +# filter_temporal +dc_y = dc \%>\% filter(.year = c(2020, 2021, 2022)) + +dc_m = dc \%>\% filter(.month = c(6,7,8)) + +dc_ym = dc \%>\% filter(.year = c(2020, 2021, 2022), .month = c(6,7,8)) # filter_temporal and filter_bbox -dc = dc \%>\% +dc2 = dc \%>\% filter(.extent = c("2021-01-01", "2021-03-03")) \%>\% filter(.extent = c(west = 6.09, east = 6.99, south = 46.15, north = 46.57)) @@ -81,7 +96,7 @@ pol <- pol_coords \%>\% st_bbox() \%>\% st_as_sfc() -dc = dc \%>\% filter(.geometries = pol) +dc = dc2 \%>\% filter(.geometries = pol) # array_filter # ToDO... diff --git a/man/group_by.Rd b/man/group_by.Rd index f69e323..7c04ade 100644 --- a/man/group_by.Rd +++ b/man/group_by.Rd @@ -98,7 +98,7 @@ be unique. The number of labels and the number of groups need to be equal.} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/mutate.Rd b/man/mutate.Rd index 4eaf333..ab7cfc4 100644 --- a/man/mutate.Rd +++ b/man/mutate.Rd @@ -88,7 +88,7 @@ resources and modifying overlapping data in subsequent operations have no effect \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/rename.Rd b/man/rename.Rd index e6e5728..885b1c3 100644 --- a/man/rename.Rd +++ b/man/rename.Rd @@ -27,7 +27,7 @@ exception if a dimension with the specified name exists.} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/resample.Rd b/man/resample.Rd index a8fb7e9..8677108 100644 --- a/man/resample.Rd +++ b/man/resample.Rd @@ -95,7 +95,7 @@ to no-data (`null`).} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/select.Rd b/man/select.Rd index d86d097..dd21f2d 100644 --- a/man/select.Rd +++ b/man/select.Rd @@ -36,7 +36,7 @@ all matched bands are included in the original order.} \item{.p}{processes available at .con} -\item{.con}{openeo connection. Default to "https://openeo.cloud"} +\item{.con}{openeo connection. Default to NULL} } \value{ datacube diff --git a/man/slice.Rd b/man/slice.Rd index cdbdc97..fba4ae5 100644 --- a/man/slice.Rd +++ b/man/slice.Rd @@ -37,7 +37,7 @@ rows, the absolute value of prop * ndays(.data) is rounded down.} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/summarise.Rd b/man/summarise.Rd index 49bb06b..12335e4 100644 --- a/man/summarise.Rd +++ b/man/summarise.Rd @@ -32,7 +32,7 @@ a `DimensionNotAvailable` exception if the specified dimension does not exist.} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/man/summarize.Rd b/man/summarize.Rd index 358024d..c020043 100644 --- a/man/summarize.Rd +++ b/man/summarize.Rd @@ -32,7 +32,7 @@ a `DimensionNotAvailable` exception if the specified dimension does not exist.} \item{.p}{(optional) processes available at .con} -\item{.con}{(optional) openeo connection. Default to "https://openeo.cloud"} +\item{.con}{(optional) openeo connection. Default to NULL} } \value{ datacube diff --git a/tests/testthat/test-filter.R b/tests/testthat/test-filter.R index c420d46..571933f 100644 --- a/tests/testthat/test-filter.R +++ b/tests/testthat/test-filter.R @@ -1,6 +1,8 @@ test_that("filter creates object of class 'datacube'", { library(sf) + con = connect(host = "https://openeo.cloud") + dc = datacube(id = "SENTINEL_5P_L2") dc_1 = dc %>% filter(.extent = c("2021-01-01", "2021-03-03")) %>% @@ -17,11 +19,22 @@ test_that("filter creates object of class 'datacube'", { dc_2 = dc %>% filter(.geometries = pol) + dc_s1 = datacube(id = "SENTINEL1_GRD") + dc_y = dc_s1 %>% filter(.year = c(2020, 2021, 2022)) + dc_m = dc_s1 %>% filter(.month = c(6,7,8)) + dc_ym = dc_s1 %>% filter(.year = c(2020, 2021, 2022), .month = c(6,7,8)) + expect_equal(all( inherits(dc_1, "datacube"), inherits(dc_1, "ProcessNode"), inherits(dc_2, "datacube"), - inherits(dc_2, "ProcessNode")), + inherits(dc_2, "ProcessNode"), + inherits(dc_y, "datacube"), + inherits(dc_y, "ProcessNode"), + inherits(dc_m, "datacube"), + inherits(dc_m, "ProcessNode"), + inherits(dc_ym, "datacube"), + inherits(dc_ym, "ProcessNode")), TRUE) }) diff --git a/tests/testthat/test-group_by.R b/tests/testthat/test-group_by.R index 3ad9032..42e180f 100644 --- a/tests/testthat/test-group_by.R +++ b/tests/testthat/test-group_by.R @@ -2,6 +2,7 @@ test_that("group_by() writes a 'datacube' object", { library(sf) +con = connect(host = "https://openeo.cloud") dc = datacube("SENTINEL_5P_L2") %>% filter(.extent = list(west = 6.09, south = 46.15, east = 6.99, north = 46.5)) %>% filter(.extent = c("2018-07-01","2018-10-31")) %>% diff --git a/tests/testthat/test-mutate.R b/tests/testthat/test-mutate.R index 591c463..d7f4674 100644 --- a/tests/testthat/test-mutate.R +++ b/tests/testthat/test-mutate.R @@ -1,5 +1,6 @@ test_that("mutate() writes a 'datacube' object", { + con = connect(host = "https://openeo.cloud") dc = datacube(id = "SENTINEL_5P_L2") dc_no2 = dc %>% diff --git a/tests/testthat/test-rename.R b/tests/testthat/test-rename.R index 4ce5396..d574020 100644 --- a/tests/testthat/test-rename.R +++ b/tests/testthat/test-rename.R @@ -1,5 +1,6 @@ test_that("rename() creates an object of class 'datacube'", { + con = connect(host = "https://openeo.cloud") dc = datacube("SENTINEL_5P_L2") %>% filter(.extent = list(west = 6.09, south = 46.15, east = 6.99, north = 46.5)) %>% filter(.extent = c("2018-07-01","2018-10-31")) %>% diff --git a/tests/testthat/test-resample.R b/tests/testthat/test-resample.R index 7a41c26..2855337 100644 --- a/tests/testthat/test-resample.R +++ b/tests/testthat/test-resample.R @@ -1,5 +1,6 @@ test_that("resample() creates an object of class 'datacube'", { + con = connect(host = "https://openeo.cloud") dc = datacube("SENTINEL_5P_L2") %>% filter(.extent = list(west = 6.09, south = 46.15, east = 6.99, north = 46.5)) %>% filter(.extent = c("2018-07-01","2018-10-31")) %>% diff --git a/tests/testthat/test-select.R b/tests/testthat/test-select.R index aa98226..fd93860 100644 --- a/tests/testthat/test-select.R +++ b/tests/testthat/test-select.R @@ -1,4 +1,5 @@ test_that("select() writes a 'datacube' object", { + con = connect(host = "https://openeo.cloud") expect_equal( all( inherits(datacube(id = "SENTINEL_5P_L2") %>% select(.bands = "CO2"), "datacube"), diff --git a/tests/testthat/test-slice.R b/tests/testthat/test-slice.R index a428c5d..fc7953a 100644 --- a/tests/testthat/test-slice.R +++ b/tests/testthat/test-slice.R @@ -1,5 +1,6 @@ test_that("slice creates object of class 'datacube'", { + con = connect(host = "https://openeo.cloud") dc = datacube(id = "SENTINEL_5P_L2") dc_1 = dc %>% filter(.extent = c("2021-01-01", "2021-03-03")) %>% diff --git a/tests/testthat/test-summarise.R b/tests/testthat/test-summarise.R index 52d8d5a..678b7a0 100644 --- a/tests/testthat/test-summarise.R +++ b/tests/testthat/test-summarise.R @@ -1,5 +1,6 @@ test_that("summarise creates object of class 'datacube'", { + con = connect(host = "https://openeo.cloud") dc = datacube("SENTINEL_5P_L2") %>% filter(.extent = list(west = 6.09, south = 46.15, east = 6.99, north = 46.5)) %>% filter(.extent = c("2018-07-01","2018-10-31")) %>% diff --git a/tests/testthat/test-summarize.R b/tests/testthat/test-summarize.R index 95b66eb..05cb687 100644 --- a/tests/testthat/test-summarize.R +++ b/tests/testthat/test-summarize.R @@ -1,5 +1,6 @@ test_that("summarize creates object of class 'datacube'", { + con = connect(host = "https://openeo.cloud") dc = datacube("SENTINEL_5P_L2") %>% filter(.extent = list(west = 6.09, south = 46.15, east = 6.99, north = 46.5)) %>% filter(.extent = c("2018-07-01","2018-10-31")) %>%