From 0e1cce1c848b3e171b0ea012670135e23cd27fec Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Mon, 20 Jun 2022 21:49:10 +0200 Subject: [PATCH 01/17] update gh actions --- .github/workflows/R-CMD-check.yaml | 85 +++++------------------------- 1 file changed, 14 insertions(+), 71 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 7fb79c3..271d466 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,18 +1,10 @@ -# NOTE: This workflow is overkill for most R packages -# check-standard.yaml is likely a better choice -# usethis::use_github_action("check-standard") will install it. -# -# For help debugging build failures open an issue on the RStudio community with the 'github-actions' tag. -# https://community.rstudio.com/new-topic?category=Package%20development&tags=github-actions +# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: R-CMD-check @@ -28,76 +20,27 @@ jobs: config: - {os: macOS-latest, r: 'release'} - {os: windows-latest, r: 'release'} - - {os: windows-latest, r: '3.6'} - - {os: ubuntu-18.04, r: 'devel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest", http-user-agent: "R/4.1.0 (ubuntu-18.04) R (4.1.0 x86_64-pc-linux-gnu x86_64 linux-gnu) on GitHub Actions" } - - {os: ubuntu-18.04, r: 'release', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: 'oldrel', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} - - {os: ubuntu-18.04, r: '3.5', rspm: "https://packagemanager.rstudio.com/cran/__linux__/bionic/latest"} + - {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'} + - {os: ubuntu-latest, r: 'release'} + - {os: ubuntu-latest, r: 'oldrel-1'} env: - RSPM: ${{ matrix.config.rspm }} GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + R_KEEP_PKG_SOURCE: yes steps: - uses: actions/checkout@v2 + - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-r@v1 - id: install-r with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} + use-public-rspm: true - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Install pak and query dependencies - run: | - install.packages("pak", repos = "https://r-lib.github.io/p/pak/dev/") - saveRDS(pak::pkg_deps("local::.", dependencies = TRUE), ".github/r-depends.rds") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v1 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1-${{ hashFiles('.github/r-depends.rds') }} - restore-keys: ${{ matrix.config.os }}-${{ steps.install-r.outputs.installed-r-version }}-1- - - - name: Install system dependencies - if: runner.os == 'Linux' - run: | - pak::local_system_requirements(execute = TRUE) - pak::pkg_system_requirements("rcmdcheck", execute = TRUE) - shell: Rscript {0} + extra-packages: rcmdcheck - - name: Install dependencies - run: | - pak::local_install_dev_deps(upgrade = TRUE) - pak::pkg_install("rcmdcheck") - shell: Rscript {0} - - - name: Session info - run: | - options(width = 100) - pkgs <- installed.packages()[, "Package"] - sessioninfo::session_info(pkgs, include_base = TRUE) - shell: Rscript {0} - - - name: Check - env: - _R_CHECK_CRAN_INCOMING_: false - run: | - options(crayon.enabled = TRUE) - rcmdcheck::rcmdcheck(args = c("--no-manual", "--as-cran"), error_on = "warning", check_dir = "check") - shell: Rscript {0} - - - name: Show testthat output - if: always() - run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true - shell: bash - - - name: Upload check results - if: failure() - uses: actions/upload-artifact@main - with: - name: ${{ matrix.config.os }}-r${{ matrix.config.r }}-results - path: check + - uses: r-lib/actions/check-r-package@v1 From b749c9a2edcdf0faef31b78d75101d4b5f5c0ff1 Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Mon, 20 Jun 2022 22:14:59 +0200 Subject: [PATCH 02/17] update gh actions to r-lib v2 --- .github/workflows/R-CMD-check.yaml | 15 ++++--- .github/workflows/lint.yaml | 41 ++++++-------------- .github/workflows/pkgdown.yaml | 58 ++++++++++++++-------------- .github/workflows/test-coverage.yaml | 43 +++++++-------------- 4 files changed, 61 insertions(+), 96 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 271d466..52c2b27 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -1,4 +1,4 @@ -# Workflow derived from https://github.com/r-lib/actions/tree/master/examples +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples # Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: @@ -31,16 +31,19 @@ jobs: steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-pandoc@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-r@v2 with: r-version: ${{ matrix.config.r }} http-user-agent: ${{ matrix.config.http-user-agent }} use-public-rspm: true - - uses: r-lib/actions/setup-r-dependencies@v1 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: rcmdcheck + extra-packages: any::rcmdcheck + needs: check - - uses: r-lib/actions/check-r-package@v1 + - uses: r-lib/actions/check-r-package@v2 + with: + upload-snapshots: true diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 82704a1..342d4bd 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -1,48 +1,29 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: lint jobs: lint: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + use-public-rspm: true - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("lintr") - shell: Rscript {0} - - - name: Install package - run: R CMD INSTALL . + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::lintr + needs: lint - name: Lint run: lintr::lint_package() diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 3c908d3..0b26021 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -1,48 +1,46 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] + pull_request: + branches: [main, master] + release: + types: [published] + workflow_dispatch: name: pkgdown jobs: pkgdown: - runs-on: macOS-latest + runs-on: ubuntu-latest + # Only restrict concurrency for non-PR jobs + concurrency: + group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }} env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@v1 + - uses: r-lib/actions/setup-pandoc@v2 - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} + - uses: r-lib/actions/setup-r@v2 + with: + use-public-rspm: true - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r-dependencies@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + extra-packages: any::pkgdown, local::. + needs: website - - name: Install dependencies - run: | - remotes::install_deps(dependencies = TRUE) - install.packages("pkgdown", type = "binary") + - name: Build site + run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE) shell: Rscript {0} - - name: Install package - run: R CMD INSTALL . - - - name: Deploy package - run: | - git config --local user.email "actions@github.com" - git config --local user.name "GitHub Actions" - Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)' + - name: Deploy to GitHub pages 🚀 + if: github.event_name != 'pull_request' + uses: JamesIves/github-pages-deploy-action@4.1.4 + with: + clean: false + branch: gh-pages + folder: docs diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 5910c1a..4b65418 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -1,48 +1,31 @@ +# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples +# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help on: push: - branches: - - main - - master + branches: [main, master] pull_request: - branches: - - main - - master + branches: [main, master] name: test-coverage jobs: test-coverage: - runs-on: macOS-latest + runs-on: ubuntu-latest env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} + steps: - uses: actions/checkout@v2 - - uses: r-lib/actions/setup-r@v1 - - - uses: r-lib/actions/setup-pandoc@v1 - - - name: Query dependencies - run: | - install.packages('remotes') - saveRDS(remotes::dev_package_deps(dependencies = TRUE), ".github/depends.Rds", version = 2) - writeLines(sprintf("R-%i.%i", getRversion()$major, getRversion()$minor), ".github/R-version") - shell: Rscript {0} - - - name: Cache R packages - uses: actions/cache@v2 + - uses: r-lib/actions/setup-r@v2 with: - path: ${{ env.R_LIBS_USER }} - key: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1-${{ hashFiles('.github/depends.Rds') }} - restore-keys: ${{ runner.os }}-${{ hashFiles('.github/R-version') }}-1- + use-public-rspm: true - - name: Install dependencies - run: | - install.packages(c("remotes")) - remotes::install_deps(dependencies = TRUE) - remotes::install_cran("covr") - shell: Rscript {0} + - uses: r-lib/actions/setup-r-dependencies@v2 + with: + extra-packages: any::covr + needs: coverage - name: Test coverage - run: covr::codecov() + run: covr::codecov(quiet = FALSE) shell: Rscript {0} From 1777e16e9268a56f0eae8f6fa4c84d7d0d3258da Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Tue, 14 Jun 2022 11:19:15 +0200 Subject: [PATCH 03/17] minor error in vignette --- vignettes/hddtools_vignette.Rmd | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/vignettes/hddtools_vignette.Rmd b/vignettes/hddtools_vignette.Rmd index e07f4cd..f00fb8a 100644 --- a/vignettes/hddtools_vignette.Rmd +++ b/vignettes/hddtools_vignette.Rmd @@ -115,7 +115,7 @@ The GRDC catalogue (or a subset) can be used to create a map. ```{r catalogueGRDC7, eval = FALSE} # Visualise outlets on an interactive map library(leaflet) -leaflet(data = GRDC_catalogue %>% filter(river == "PO, FIUME")) %>% +leaflet(data = GRDC_catalogue %>% dplyr::filter(river == "PO, FIUME")) %>% addTiles() %>% # Add default OpenStreetMap map tiles addMarkers(~long, ~lat, popup = ~station) ``` From 3a984093927672025d7768530ecd248c70de356a Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Tue, 14 Jun 2022 15:50:52 +0200 Subject: [PATCH 04/17] remove dependency from sp and raster for the bboxSpatialPolygon function --- R/bboxSpatialPolygon.R | 60 +++++++++++++++++------- tests/testthat/test-bboxSpatialPolygon.R | 4 +- 2 files changed, 44 insertions(+), 20 deletions(-) diff --git a/R/bboxSpatialPolygon.R b/R/bboxSpatialPolygon.R index 524d78a..cd2979f 100644 --- a/R/bboxSpatialPolygon.R +++ b/R/bboxSpatialPolygon.R @@ -15,43 +15,67 @@ #' #' @examples #' \dontrun{ -#' boundingbox <- raster::extent(-180, +180, -50, +50) -#' bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) +#' boundingbox <- raster::extent(-180, +180, -50, +50) +#' bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) #' } #' - bboxSpatialPolygon <- function(boundingbox, proj4stringFrom = NULL, proj4stringTo = NULL) { + if (!is.null(proj4stringFrom)) { + stopifnot(class(proj4stringFrom) == "crs") + } if (is.null(proj4stringFrom)) { + proj4stringFrom <- sf::st_crs("+proj=longlat +datum=WGS84") + } - proj4stringFrom <- sp::CRS("+proj=longlat +datum=WGS84") + if(is.matrix(boundingbox)) if(dim(boundingbox)==c(2,2)) bb <- boundingbox + + #For compatibility with raster input bounding box objects + if(class(boundingbox) == "Extent"){ + bb <- matrix(as.numeric(c( + boundingbox@xmin, boundingbox@ymin, + boundingbox@xmax, boundingbox@ymax + )), + nrow = 2 + )} - } - bb <- matrix(as.numeric(c(boundingbox@xmin, boundingbox@ymin, - boundingbox@xmax, boundingbox@ymax)), - nrow = 2) + if(class(boundingbox) == "SpatExtent"){ + bb <- matrix(as.numeric(c( + boundingbox$xmin, boundingbox$ymin, + boundingbox$xmax, boundingbox$ymax + )), + nrow = 2 + )} + + if(!exists("bb")) stop("No valid bounding box provided") + rownames(bb) <- c("lon", "lat") colnames(bb) <- c("min", "max") # Create unprojected boundingbox as spatial object # clockwise, 5 points to close it - bboxMat <- rbind(c(bb["lon", "min"], bb["lat", "min"]), - c(bb["lon", "min"], bb["lat", "max"]), - c(bb["lon", "max"], bb["lat", "max"]), - c(bb["lon", "max"], bb["lat", "min"]), - c(bb["lon", "min"], bb["lat", "min"])) + bboxMat <- rbind( + c(bb["lon", "min"], bb["lat", "min"]), + c(bb["lon", "min"], bb["lat", "max"]), + c(bb["lon", "max"], bb["lat", "max"]), + c(bb["lon", "max"], bb["lat", "min"]), + c(bb["lon", "min"], bb["lat", "min"]) + ) + + bboxSP <- bboxMat %>% + list() %>% + sf::st_polygon() %>% + sf::st_sfc(., crs = proj4stringFrom) + - bboxSP <- sp::SpatialPolygons(list(sp::Polygons(list(sp::Polygon(bboxMat)), - "bbox")), - proj4string = proj4stringFrom) if (!is.null(proj4stringTo)) { - bboxSP <- sp::spTransform(bboxSP, proj4stringTo) + stopifnot(class(proj4stringTo) == "crs") + bboxSP <- sf::sf_project(bboxSP, proj4stringTo) } return(bboxSP) - } diff --git a/tests/testthat/test-bboxSpatialPolygon.R b/tests/testthat/test-bboxSpatialPolygon.R index 32d2ae6..e9c6f23 100644 --- a/tests/testthat/test-bboxSpatialPolygon.R +++ b/tests/testthat/test-bboxSpatialPolygon.R @@ -2,9 +2,9 @@ context("bboxSpatialPolygon") test_that("Test bboxSpatialPolygon function", { - boundingbox <- raster::extent(c(-180, +180, -50, +50)) + boundingbox <- terra::ext(c(-180, +180, -50, +50)) bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) - expect_that("SpatialPolygons" %in% class(bbSP), equals(TRUE)) + expect_that("sfc_POLYGON" %in% class(bbSP), equals(TRUE)) }) From e0f06fb9accabf6644e78e64461624b2418fd12e Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Wed, 15 Jun 2022 11:47:26 +0200 Subject: [PATCH 05/17] fix new terra syntax --- R/KGClimateClass.R | 12 ++++++------ R/bboxSpatialPolygon.R | 10 +++------- man/KGClimateClass.Rd | 2 +- man/bboxSpatialPolygon.Rd | 4 ++-- 4 files changed, 12 insertions(+), 16 deletions(-) diff --git a/R/KGClimateClass.R b/R/KGClimateClass.R index 856dcea..fc674d3 100644 --- a/R/KGClimateClass.R +++ b/R/KGClimateClass.R @@ -17,7 +17,7 @@ #' @examples #' \dontrun{ #' # Define a bounding box -#' areaBox <- raster::extent(-3.82, -3.63, 52.41, 52.52) +#' areaBox <- terra::ext(-3.82, -3.63, 52.41, 52.52) #' # Get climate classes #' KGClimateClass(areaBox = areaBox) #' } @@ -28,7 +28,7 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ # crop to bounding box if (is.null(areaBox)){ - areaBox <- raster::extent(c(-180, +180, -90, +90)) + areaBox <- terra::ext(c(-180, +180, -90, +90)) } bbSP <- bboxSpatialPolygon(areaBox) @@ -50,10 +50,10 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ utils::untar(system.file(file.path("extdata", "KOTTEK_KG.tar.gz"), package = "hddtools"), exdir = td) - kgRaster <- raster::raster(paste0(td, "/KOTTEK_koeppen-geiger.tiff", + kgRaster <- terra::rast(paste0(td, "/KOTTEK_koeppen-geiger.tiff", sep = "")) - temp <- data.frame(table(raster::extract(kgRaster, bbSP))) + temp <- data.frame(table(terra::extract(kgRaster, bbSP))) temp$Class <- NA for (i in 1:dim(temp)[1]){ class1 <- which(kgLegend[,1] == temp[i,1]) @@ -89,9 +89,9 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ utils::untar(system.file(file.path("extdata", "PEEL_KG.tar.gz"), package = "hddtools"), exdir = td) - kgRaster <- raster::raster(paste0(td, "/PEEL_koppen_ascii.txt", sep = "")) + kgRaster <- terra::rast(paste0(td, "/PEEL_koppen_ascii.txt", sep = "")) - temp <- data.frame(table(raster::extract(kgRaster, bbSP))) + temp <- data.frame(table(terra::extract(kgRaster, bbSP))) temp$Class <- NA for (i in 1:dim(temp)[1]){ class1 <- which(kgLegend[,1] == temp[i,1]) diff --git a/R/bboxSpatialPolygon.R b/R/bboxSpatialPolygon.R index cd2979f..2b27773 100644 --- a/R/bboxSpatialPolygon.R +++ b/R/bboxSpatialPolygon.R @@ -15,7 +15,7 @@ #' #' @examples #' \dontrun{ -#' boundingbox <- raster::extent(-180, +180, -50, +50) +#' boundingbox <- terra::ext(-180, +180, -50, +50) #' bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) #' } #' @@ -27,7 +27,7 @@ bboxSpatialPolygon <- function(boundingbox, } if (is.null(proj4stringFrom)) { - proj4stringFrom <- sf::st_crs("+proj=longlat +datum=WGS84") + proj4stringFrom <- "+proj=longlat +datum=WGS84" } if(is.matrix(boundingbox)) if(dim(boundingbox)==c(2,2)) bb <- boundingbox @@ -65,12 +65,8 @@ bboxSpatialPolygon <- function(boundingbox, c(bb["lon", "min"], bb["lat", "min"]) ) - bboxSP <- bboxMat %>% - list() %>% - sf::st_polygon() %>% - sf::st_sfc(., crs = proj4stringFrom) - + bboxSP <- terra::vect(bboxMat, "polygon", crs = proj4stringFrom) if (!is.null(proj4stringTo)) { stopifnot(class(proj4stringTo) == "crs") diff --git a/man/KGClimateClass.Rd b/man/KGClimateClass.Rd index 96b0816..d5b9996 100644 --- a/man/KGClimateClass.Rd +++ b/man/KGClimateClass.Rd @@ -22,7 +22,7 @@ Given a bounding box, the function identifies the overlapping climate zones. \examples{ \dontrun{ # Define a bounding box - areaBox <- raster::extent(-3.82, -3.63, 52.41, 52.52) + areaBox <- terra::ext(-3.82, -3.63, 52.41, 52.52) # Get climate classes KGClimateClass(areaBox = areaBox) } diff --git a/man/bboxSpatialPolygon.Rd b/man/bboxSpatialPolygon.Rd index b28cb11..b870906 100644 --- a/man/bboxSpatialPolygon.Rd +++ b/man/bboxSpatialPolygon.Rd @@ -25,8 +25,8 @@ Bounding box is first created (in lat/lon) then projected if specified } \examples{ \dontrun{ - boundingbox <- raster::extent(-180, +180, -50, +50) - bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) +boundingbox <- terra::ext(-180, +180, -50, +50) +bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) } } From 66e742025baa4804d81ab5f37f3bfe1839d04a4f Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Wed, 15 Jun 2022 12:39:32 +0200 Subject: [PATCH 06/17] fix new syntax --- R/Data60UK.R | 14 +++++++------- R/KGClimateClass.R | 18 ++++++++++-------- R/bboxSpatialPolygon.R | 6 +++--- man/catalogueData60UK.Rd | 2 +- tests/testthat/test-KGClimateClass.R | 2 +- vignettes/hddtools_vignette.Rmd | 2 +- 6 files changed, 23 insertions(+), 21 deletions(-) diff --git a/R/Data60UK.R b/R/Data60UK.R index e3cdd96..5a0d277 100644 --- a/R/Data60UK.R +++ b/R/Data60UK.R @@ -18,7 +18,7 @@ #' \item{\code{Latitude}}{} #' \item{\code{Longitude}}{} #' } -#' +#' #' @source \url{http://nrfaapps.ceh.ac.uk/datauk60/data.html} #' #' @export @@ -29,7 +29,7 @@ #' Data60UK_catalogue_all <- catalogueData60UK() #' #' # Filter the catalogue based on a bounding box -#' areaBox <- raster::extent(-4, -2, +52, +53) +#' areaBox <- terra::ext(-4, -2, +52, +53) #' Data60UK_catalogue_bbox <- catalogueData60UK(areaBox) #' } #' @@ -43,13 +43,13 @@ catalogueData60UK <- function(areaBox = NULL){ Data60UKcatalogue <- tables[[which.max(n.rows)]] names(Data60UKcatalogue) <- c("id", "River", "Location") Data60UKcatalogue[] <- lapply(Data60UKcatalogue, as.character) - + # Find grid reference browsing the NRFA catalogue # This was temp <- rnrfa::catalogue() but the catalogue has been saved as # external data here so that the dependency from rnrfa could be removed. temp <- readRDS(system.file("extdata", "rnrfa_cat.rds", package = "hddtools")) temp <- temp[which(temp$id %in% Data60UKcatalogue$id), ] - + Data60UKcatalogue$gridReference <- temp$`grid-reference`$ngr Data60UKcatalogue$Latitude <- temp$latitude Data60UKcatalogue$Longitude <- temp$longitude @@ -103,16 +103,16 @@ tsData60UK <- function(id){ temp <- utils::read.table(file_url) names(temp) <- c("P", "Q", "DayNumber", "Year", "nStations") - + # Combine the first four columns into a character vector date_info <- with(temp, paste(Year, DayNumber)) # Parse that character vector datetime <- strptime(date_info, "%Y %j") P <- zoo::zoo(temp$P, order.by = datetime) # measured in mm Q <- zoo::zoo(temp$Q, order.by = datetime) # measured in m3/s - + myTS <- zoo::merge.zoo(P,Q) - + return(myTS) } diff --git a/R/KGClimateClass.R b/R/KGClimateClass.R index fc674d3..a7c6c9f 100644 --- a/R/KGClimateClass.R +++ b/R/KGClimateClass.R @@ -38,7 +38,7 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ kgLegend <- utils::read.table(system.file(file.path("extdata", "KOTTEK_Legend.txt"), package = "hddtools")) - + kgLegend$V1 <- as.character(kgLegend$V1) # message("OFFLINE results") # create a temporary directory @@ -53,10 +53,11 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ kgRaster <- terra::rast(paste0(td, "/KOTTEK_koeppen-geiger.tiff", sep = "")) - temp <- data.frame(table(terra::extract(kgRaster, bbSP))) + temp <- data.frame(table(terra::extract(kgRaster, bbSP)))[,2:3] + colnames(temp)[1] <- "ID" temp$Class <- NA for (i in 1:dim(temp)[1]){ - class1 <- which(kgLegend[,1] == temp[i,1]) + class1 <- which(kgLegend[,1] == as.character(temp[i,1])) if (length(class1) > 0){ temp$Class[i] <- as.character(kgLegend[class1,3]) } @@ -64,7 +65,7 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ temp <- temp[which(!is.na(temp$Class)),] - df <- data.frame(ID = temp$Var1, + df <- data.frame(ID = temp$ID, Class = temp$Class, Frequency = temp$Freq) @@ -77,7 +78,7 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ "PEEL_Legend.txt"), package = "hddtools"), header = TRUE) - + kgLegend$ID <- as.character(kgLegend$ID) # message("OFFLINE results") # create a temporary directory @@ -91,10 +92,11 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ kgRaster <- terra::rast(paste0(td, "/PEEL_koppen_ascii.txt", sep = "")) - temp <- data.frame(table(terra::extract(kgRaster, bbSP))) + temp <- data.frame(table(terra::extract(kgRaster, bbSP)))[,2:3] + colnames(temp)[1] <- "ID" temp$Class <- NA for (i in 1:dim(temp)[1]){ - class1 <- which(kgLegend[,1] == temp[i,1]) + class1 <- which(kgLegend[,1] == as.character(temp[i,1])) if (length(class1) > 0){ temp$Class[i] <- as.character(kgLegend[class1,2]) } @@ -102,7 +104,7 @@ KGClimateClass <- function(areaBox = NULL, updatedBy = "Peel", verbose = FALSE){ temp <- temp[which(!is.na(temp$Class)),] - df <- data.frame(ID = temp$Var1, + df <- data.frame(ID = temp$ID, Class = temp$Class, Frequency = temp$Freq) diff --git a/R/bboxSpatialPolygon.R b/R/bboxSpatialPolygon.R index 2b27773..8c124df 100644 --- a/R/bboxSpatialPolygon.R +++ b/R/bboxSpatialPolygon.R @@ -23,7 +23,7 @@ bboxSpatialPolygon <- function(boundingbox, proj4stringFrom = NULL, proj4stringTo = NULL) { if (!is.null(proj4stringFrom)) { - stopifnot(class(proj4stringFrom) == "crs") + stopifnot(class(sf::st_crs(proj4stringFrom)) == "crs") } if (is.null(proj4stringFrom)) { @@ -69,8 +69,8 @@ bboxSpatialPolygon <- function(boundingbox, bboxSP <- terra::vect(bboxMat, "polygon", crs = proj4stringFrom) if (!is.null(proj4stringTo)) { - stopifnot(class(proj4stringTo) == "crs") - bboxSP <- sf::sf_project(bboxSP, proj4stringTo) + stopifnot(class(sf::st_crs(proj4stringTo)) == "crs") + bboxSP <- terra::project(bboxSP, proj4stringTo) } return(bboxSP) diff --git a/man/catalogueData60UK.Rd b/man/catalogueData60UK.Rd index 6c01a89..18741cb 100644 --- a/man/catalogueData60UK.Rd +++ b/man/catalogueData60UK.Rd @@ -35,7 +35,7 @@ listing 61 gauging stations. Data60UK_catalogue_all <- catalogueData60UK() # Filter the catalogue based on a bounding box - areaBox <- raster::extent(-4, -2, +52, +53) + areaBox <- terra::ext(-4, -2, +52, +53) Data60UK_catalogue_bbox <- catalogueData60UK(areaBox) } diff --git a/tests/testthat/test-KGClimateClass.R b/tests/testthat/test-KGClimateClass.R index c1e5d95..c08a82c 100644 --- a/tests/testthat/test-KGClimateClass.R +++ b/tests/testthat/test-KGClimateClass.R @@ -3,7 +3,7 @@ context("KGClimateClass") test_that("Test KGClimateClass function", { # Define a bounding box - areaBox <- raster::extent(-3.82, -3.63, 52.41, 52.52) + areaBox <- terra::ext(-3.82, -3.63, 52.41, 52.52) # Get climate classes x <- try(KGClimateClass(areaBox = areaBox), silent = TRUE) diff --git a/vignettes/hddtools_vignette.Rmd b/vignettes/hddtools_vignette.Rmd index f00fb8a..734a875 100644 --- a/vignettes/hddtools_vignette.Rmd +++ b/vignettes/hddtools_vignette.Rmd @@ -63,7 +63,7 @@ The package hddtools contains a function to identify the updated Koppen-Greiger ```{r KGClimateClass1, eval = TRUE} # Define a bounding box -areaBox <- raster::extent(-10, 5, 48, 62) +areaBox <- terra::ext(-10, 5, 48, 62) # Extract climate zones from Peel's map: KGClimateClass(areaBox = areaBox, updatedBy = "Peel") From 516a43892a3f2147c4872f1fd7ca34c0b24c87d3 Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Wed, 15 Jun 2022 14:37:52 +0200 Subject: [PATCH 07/17] remove further {raster} dependencies --- DESCRIPTION | 4 +- NAMESPACE | 8 --- R/Data60UK.R | 10 ++-- R/hddtools-package.R | 3 - inst/experimental/moreGRDC.R | 76 ++++++++++++------------ man/catalogueData60UK.Rd | 2 +- tests/testthat/test-Data60UK.R | 8 +-- tests/testthat/test-bboxSpatialPolygon.R | 2 +- vignettes/hddtools_vignette.Rmd | 2 +- 9 files changed, 52 insertions(+), 63 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 00e9ed4..3f2b9b4 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -15,8 +15,8 @@ Maintainer: Dorothea Hug Peter URL: https://docs.ropensci.org/hddtools/, https://github.com/ropensci/hddtools BugReports: https://github.com/ropensci/hddtools/issues Description: Tools to discover hydrological data, accessing catalogues and databases from various data providers. The package is described in Vitolo (2017) "hddtools: Hydrological Data Discovery Tools" . -Depends: R (>= 3.5.0), rgdal -Imports: zoo, sp, curl, XML, raster, readxl, tidyr +Depends: R (>= 3.5.0) +Imports: zoo, curl, XML, terra, readxl, tidyr Suggests: testthat, leaflet, rmarkdown, knitr, dplyr VignetteBuilder: knitr License: GPL-3 diff --git a/NAMESPACE b/NAMESPACE index c492d42..0c74fcc 100644 --- a/NAMESPACE +++ b/NAMESPACE @@ -9,17 +9,9 @@ export(catalogueSEPA) export(tsData60UK) export(tsMOPEX) export(tsSEPA) -import(rgdal) importFrom(XML,readHTMLTable) importFrom(curl,curl_download) -importFrom(raster,extent) -importFrom(raster,extract) -importFrom(raster,raster) importFrom(readxl,read_xlsx) -importFrom(sp,CRS) -importFrom(sp,Polygon) -importFrom(sp,Polygons) -importFrom(sp,SpatialPolygons) importFrom(tidyr,pivot_longer) importFrom(utils,download.file) importFrom(utils,read.csv) diff --git a/R/Data60UK.R b/R/Data60UK.R index 5a0d277..f2671cd 100644 --- a/R/Data60UK.R +++ b/R/Data60UK.R @@ -7,7 +7,7 @@ #' #' @param areaBox bounding box, a list made of 4 elements: minimum longitude #' (lonMin), minimum latitude (latMin), maximum longitude (lonMax), maximum -#' latitude (latMax) +#' latitude (latMax) or an object of type "SpatExtent" #' #' @return This function returns a data frame containing the following columns: #' \describe{ @@ -56,10 +56,10 @@ catalogueData60UK <- function(areaBox = NULL){ # Latitude is the Y axis, longitude is the X axis. if (!is.null(areaBox)){ - lonMin <- areaBox@xmin - lonMax <- areaBox@xmax - latMin <- areaBox@ymin - latMax <- areaBox@ymax + lonMin <- areaBox$xmin + lonMax <- areaBox$xmax + latMin <- areaBox$ymin + latMax <- areaBox$ymax }else{ lonMin <- -180 lonMax <- +180 diff --git a/R/hddtools-package.R b/R/hddtools-package.R index a9dfd56..36b4468 100644 --- a/R/hddtools-package.R +++ b/R/hddtools-package.R @@ -18,11 +18,8 @@ #' Vitolo C, Buytaert W, 2014, HDDTOOLS: an R package serving Hydrological Data #' Discovery Tools, AGU Fall Meeting, 15-19 December 2014, San Francisco, USA. #' -#' @import rgdal #' @importFrom curl curl_download -#' @importFrom raster raster extract extent #' @importFrom readxl read_xlsx -#' @importFrom sp CRS SpatialPolygons Polygon Polygons #' @importFrom tidyr pivot_longer #' @importFrom utils download.file read.csv read.fwf read.table untar unzip #' @importFrom XML readHTMLTable diff --git a/inst/experimental/moreGRDC.R b/inst/experimental/moreGRDC.R index 325dcd3..e2a6d51 100644 --- a/inst/experimental/moreGRDC.R +++ b/inst/experimental/moreGRDC.R @@ -46,7 +46,7 @@ #' GRDC_catalogue_all <- catalogueGRDC() #' #' # Define a bounding box -#' areaBox <- raster::extent(-3.82, -3.63, 52.41, 52.52) +#' areaBox <- terra::ext(-3.82, -3.63, 52.41, 52.52) #' # Filter the catalogue based on bounding box #' GRDC_catalogue_bbox <- catalogueGRDC(areaBox = areaBox) #' @@ -61,39 +61,39 @@ #' test_catalogueGRDC <- function() { - + the_url <- "ftp://ftp.bafg.de/pub/REFERATE/GRDC/catalogue/" - + # Retrieve the catalogue result <- RCurl::getURL(the_url, ftp.use.epsv=TRUE, dirlistonly = TRUE) list_of_files <- strsplit(result, "\r*\n")[[1]] yesterday <- gsub(pattern = "-", replacement = "_", Sys.Date() - 1) today <- gsub(pattern = "-", replacement = "_", Sys.Date()) - latest_file <- + latest_file <- ifelse(test = length(list_of_files[grep(pattern = today, x = list_of_files)]), yes = list_of_files[grep(pattern = today, x = list_of_files)], no = list_of_files[grep(pattern = yesterday, x = list_of_files)]) latest_file <- paste0(the_url, latest_file) - + my_tmp_file <- tempfile() x <- RCurl::getBinaryURL(latest_file, ftp.use.epsv = FALSE,crlf = TRUE) writeBin(object = x, con = my_tmp_file) GRDCcatalogue <- readxl::read_xlsx(my_tmp_file, sheet = "Catalogue") - + # Cleanup non GRDCcatalogue <- data.frame(lapply(GRDCcatalogue, function(x) {gsub("n.a.|-999|-", NA, x)}), stringsAsFactors = FALSE) - + # Convert to numeric some of the columns colx <- which(!(names(GRDCcatalogue) %in% c("grdc_no", "wmo_reg", "sub_reg", "nat_id", "river", "station", "country", "provider_id"))) GRDCcatalogue[, colx] <- lapply(GRDCcatalogue[, colx], as.numeric) - + return(GRDCcatalogue) - + } #' Interface for the Global Runoff Data Centre database of Monthly Time Series. @@ -233,58 +233,58 @@ test_catalogueGRDC <- function() { #' test_tsGRDC <- function(id) { - + options(warn = -1) - + catalogueTmp <- catalogueGRDC() catalogueTmp <- catalogueTmp[which(catalogueTmp$grdc_no == id), ] - + # Retrieve look-up table grdcLTMMD <- NULL load(system.file(file.path("data", "grdcLTMMD.rda"), package = "hddtools")) - + # Retrieve WMO region from catalogue wmoRegion <- catalogueTmp$wmo_reg - + # Retrieve ftp server location zipFile <- as.character(grdcLTMMD[which(grdcLTMMD$WMO_Region == wmoRegion), "Archive"]) - + # create a temporary directory td <- tempdir() - + # create the placeholder file tf <- tempfile(tmpdir = td, fileext = ".zip") - + # download into the placeholder file # Switched from downloader::download to utils::download.file # to ensure it works cross-platform downloader::download(url = zipFile, destfile = tf, mode = "wb") - + # Type of tables tablenames <- c("LTVD", "LTVM", "PVD", "PVM", "YVD", "YVM") - + # get the name of the file to unzip fname <- paste0(id, "_Q_", tablenames, ".csv") - + # unzip the file to the temporary directory utils::unzip(tf, files = fname, exdir = td, overwrite = TRUE) - + # fpath is the full path to the extracted file fpath <- file.path(td, fname) - + if (!all(file.exists(fpath))) { - + stop("Data are not available at this station") - + } - + # Initialise empty list of tables ltables <- list() - + # Populate tables for (j in seq_along(fpath)) { - + TS <- readLines(fpath[j]) # find dataset content row_data <- grep(pattern = "# Data Set Content:", x = TS) @@ -295,7 +295,7 @@ test_tsGRDC <- function(id) { data_names <- gsub(pattern = ")", replacement = "", x = data_names) data_names <- gsub(pattern = "\\(", replacement = "_", x = data_names) data_names <- gsub(pattern = "\\.", replacement = "_", x = data_names) - + ## find data lines row_data_lines <- grep(pattern = "# Data lines:", x = TS)[1] chr_positions <- gregexpr(pattern = "[0-9]", @@ -304,14 +304,14 @@ test_tsGRDC <- function(id) { rows_to_read <- as.numeric(substr(x = TS[row_data_lines], start = chr_positions[1], stop = chr_positions[lchr_positions])) - + if (rows_to_read > 0) { - + # find tables row_data <- grep(pattern = "DATA", x = TS, ignore.case = FALSE) row_start <- row_data + 2 row_end <- row_start + rows_to_read - 1 - + # Read columns and assign names column_names <- c() for (k in seq_along(data_names)) { @@ -322,7 +322,7 @@ test_tsGRDC <- function(id) { column_names <- c(column_names, paste0(data_names[k], "__", tempcolnames)) } - + for (w in seq_along(row_start)) { # Assemble data frame row_split <- unlist(strsplit(TS[row_start[w]:row_end[w]], ";")) @@ -334,20 +334,20 @@ test_tsGRDC <- function(id) { byrow = TRUE)) } } - + df <- data.frame(tmp, stringsAsFactors = FALSE) names(df) <- column_names - + ltables[[j]] <- df }else{ message(paste(tablenames[j], "data are not available at this station")) ltables[[j]] <- NULL } - + } - + names(ltables) <- tablenames - + return(ltables) - + } diff --git a/man/catalogueData60UK.Rd b/man/catalogueData60UK.Rd index 18741cb..46ac9a0 100644 --- a/man/catalogueData60UK.Rd +++ b/man/catalogueData60UK.Rd @@ -12,7 +12,7 @@ catalogueData60UK(areaBox = NULL) \arguments{ \item{areaBox}{bounding box, a list made of 4 elements: minimum longitude (lonMin), minimum latitude (latMin), maximum longitude (lonMax), maximum -latitude (latMax)} +latitude (latMax) or an object of type "SpatExtent"} } \value{ This function returns a data frame containing the following columns: diff --git a/tests/testthat/test-Data60UK.R b/tests/testthat/test-Data60UK.R index 85b661b..6555f74 100644 --- a/tests/testthat/test-Data60UK.R +++ b/tests/testthat/test-Data60UK.R @@ -13,7 +13,7 @@ test_that("Test catalogueData60UK", { test_that("Test catalogueData60UK bounding box", { # Define a bounding box - areaBox <- raster::extent(c(-4, -2, +52, +53)) + areaBox <- terra::ext(c(-4, -2, +52, +53)) # Filter the catalogue based on a bounding box x2 <- catalogueData60UK(areaBox) @@ -22,11 +22,11 @@ test_that("Test catalogueData60UK bounding box", { }) test_that("Test tsData60UK function", { - + # Retrieve sample data x <- tsData60UK(id = 39015) - + expect_that(class(x) == "zoo", equals(TRUE)) expect_that(all(names(x) == c("P", "Q")), equals(TRUE)) - + }) diff --git a/tests/testthat/test-bboxSpatialPolygon.R b/tests/testthat/test-bboxSpatialPolygon.R index e9c6f23..823cb7b 100644 --- a/tests/testthat/test-bboxSpatialPolygon.R +++ b/tests/testthat/test-bboxSpatialPolygon.R @@ -5,6 +5,6 @@ test_that("Test bboxSpatialPolygon function", { boundingbox <- terra::ext(c(-180, +180, -50, +50)) bbSP <- bboxSpatialPolygon(boundingbox = boundingbox) - expect_that("sfc_POLYGON" %in% class(bbSP), equals(TRUE)) + expect_that("SpatVector" %in% class(bbSP), equals(TRUE)) }) diff --git a/vignettes/hddtools_vignette.Rmd b/vignettes/hddtools_vignette.Rmd index 734a875..53e27bc 100644 --- a/vignettes/hddtools_vignette.Rmd +++ b/vignettes/hddtools_vignette.Rmd @@ -134,7 +134,7 @@ The hddtools contain two functions to interact with this database: one to retrei Data60UK_catalogue_all <- catalogueData60UK() # Filter Data60UK catalogue based on bounding box -areaBox <- raster::extent(-4, -3, 51, 53) +areaBox <- terra::ext(-4, -3, 51, 53) Data60UK_catalogue_bbox <- catalogueData60UK(areaBox = areaBox) ``` From d1671afda19991b676f9e321de9922a203d4164c Mon Sep 17 00:00:00 2001 From: dhugpeter Date: Wed, 15 Jun 2022 22:38:24 +0200 Subject: [PATCH 08/17] import sf --- DESCRIPTION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 3f2b9b4..75a4358 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -16,7 +16,7 @@ URL: https://docs.ropensci.org/hddtools/, https://github.com/ropensci/hddtools BugReports: https://github.com/ropensci/hddtools/issues Description: Tools to discover hydrological data, accessing catalogues and databases from various data providers. The package is described in Vitolo (2017) "hddtools: Hydrological Data Discovery Tools" . Depends: R (>= 3.5.0) -Imports: zoo, curl, XML, terra, readxl, tidyr +Imports: zoo, curl, XML, terra, readxl, tidyr, sf Suggests: testthat, leaflet, rmarkdown, knitr, dplyr VignetteBuilder: knitr License: GPL-3 From 22aa07c7e1aa711aa875e72a7efe075fd9b5d995 Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Mon, 27 Jun 2022 23:05:08 +0200 Subject: [PATCH 09/17] remove tsMOPEX test on CI for now --- tests/testthat/test-MOPEX.R | 20 +++++++++++--------- 1 file changed, 11 insertions(+), 9 deletions(-) diff --git a/tests/testthat/test-MOPEX.R b/tests/testthat/test-MOPEX.R index 778e332..08ef6fa 100644 --- a/tests/testthat/test-MOPEX.R +++ b/tests/testthat/test-MOPEX.R @@ -6,7 +6,7 @@ test_that("Test catalogueMOPEX - MAP = FALSE", { # Retrieve the MOPEX catalogue x1 <- catalogueMOPEX(MAP = FALSE) - + expect_true("data.frame" %in% class(x1)) expect_true(all(dim(x1) == c(1861, 12))) expect_true(is.na(x1$State[x1$USGS_ID == "08167000"])) @@ -16,38 +16,40 @@ test_that("Test catalogueMOPEX - MAP = FALSE", { test_that("Test catalogueMOPEX - MAP = TRUE", { testthat::skip_on_cran() + testthat::ski_on_ci() + # Retrieve the MOPEX catalogue x2 <- catalogueMOPEX(MAP = TRUE) - + expect_true("data.frame" %in% class(x2)) expect_true(all(dim(x2) == c(438, 12))) expect_true(x2$State[x2$USGS_ID == "01048000"] == "ME") - + }) test_that("Test tsMOPEX - MAP = FALSE", { testthat::skip_on_cran() - + testthat::ski_on_ci() # Retrieve data x3 <- tsMOPEX(id = "01010000", MAP = FALSE) - + expect_true("zoo" %in% class(x3)) expect_true(all(names(x3) == "Q")) expect_true(as.numeric(x3$Q[1]) == 13.45) - + }) test_that("Test tsMOPEX - MAP = TRUE", { testthat::skip_on_cran() - + testthat::ski_on_ci() # Retrieve data x4 <- tsMOPEX(id = "01048000", MAP = TRUE) - + expect_true("zoo" %in% class(x4)) expect_true(all(names(x4) == c("P", "E", "Q", "T_max", "T_min"))) expect_true(as.numeric(x4$T_min[1]) == -10.8444) - + }) From d4fa74876639013b84b5e09816a590c97aa6d1a1 Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Mon, 27 Jun 2022 23:14:47 +0200 Subject: [PATCH 10/17] fix gh-actions --- .github/workflows/R-CMD-check.yaml | 2 +- .github/workflows/lint.yaml | 2 +- .github/workflows/pkgdown.yaml | 2 +- .github/workflows/test-coverage.yaml | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/.github/workflows/R-CMD-check.yaml b/.github/workflows/R-CMD-check.yaml index 52c2b27..67b00c6 100644 --- a/.github/workflows/R-CMD-check.yaml +++ b/.github/workflows/R-CMD-check.yaml @@ -41,7 +41,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::rcmdcheck + extra-packages: any::rcmdcheck any::XML needs: check - uses: r-lib/actions/check-r-package@v2 diff --git a/.github/workflows/lint.yaml b/.github/workflows/lint.yaml index 342d4bd..e7b89bb 100644 --- a/.github/workflows/lint.yaml +++ b/.github/workflows/lint.yaml @@ -22,7 +22,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::lintr + extra-packages: any::lintr any::XML needs: lint - name: Lint diff --git a/.github/workflows/pkgdown.yaml b/.github/workflows/pkgdown.yaml index 0b26021..89b145a 100644 --- a/.github/workflows/pkgdown.yaml +++ b/.github/workflows/pkgdown.yaml @@ -30,7 +30,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::pkgdown, local::. + extra-packages: any::pkgdown, local::. any::XML needs: website - name: Build site diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 4b65418..335d954 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -23,7 +23,7 @@ jobs: - uses: r-lib/actions/setup-r-dependencies@v2 with: - extra-packages: any::covr + extra-packages: any::covr any::XML needs: coverage - name: Test coverage From d9aa58d06a106d8f048ba420d5402553de5678e4 Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Mon, 27 Jun 2022 23:53:45 +0200 Subject: [PATCH 11/17] fix typo --- tests/testthat/test-MOPEX.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/testthat/test-MOPEX.R b/tests/testthat/test-MOPEX.R index 08ef6fa..2b6c84f 100644 --- a/tests/testthat/test-MOPEX.R +++ b/tests/testthat/test-MOPEX.R @@ -16,7 +16,7 @@ test_that("Test catalogueMOPEX - MAP = FALSE", { test_that("Test catalogueMOPEX - MAP = TRUE", { testthat::skip_on_cran() - testthat::ski_on_ci() + testthat::skip_on_ci() # Retrieve the MOPEX catalogue @@ -31,7 +31,7 @@ test_that("Test catalogueMOPEX - MAP = TRUE", { test_that("Test tsMOPEX - MAP = FALSE", { testthat::skip_on_cran() - testthat::ski_on_ci() + testthat::skip_on_ci() # Retrieve data x3 <- tsMOPEX(id = "01010000", MAP = FALSE) @@ -44,7 +44,7 @@ test_that("Test tsMOPEX - MAP = FALSE", { test_that("Test tsMOPEX - MAP = TRUE", { testthat::skip_on_cran() - testthat::ski_on_ci() + testthat::skip_on_ci() # Retrieve data x4 <- tsMOPEX(id = "01048000", MAP = TRUE) From 43f6100aabb80344f86384ac7c017369d87d24be Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Tue, 28 Jun 2022 11:09:22 +0200 Subject: [PATCH 12/17] skip Mopex test on ci --- tests/testthat/test-MOPEX.R | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/testthat/test-MOPEX.R b/tests/testthat/test-MOPEX.R index 2b6c84f..327965d 100644 --- a/tests/testthat/test-MOPEX.R +++ b/tests/testthat/test-MOPEX.R @@ -3,6 +3,7 @@ context("MOPEX") test_that("Test catalogueMOPEX - MAP = FALSE", { testthat::skip_on_cran() + testthat::skip_on_ci() # Retrieve the MOPEX catalogue x1 <- catalogueMOPEX(MAP = FALSE) From f287ddccb8cbcd71dabd30cf0a5e2b0b2ee613ca Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Tue, 28 Jun 2022 13:38:13 +0200 Subject: [PATCH 13/17] remove tsGRDC doc --- _pkgdown.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index eb5bae5..bfb32d3 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -34,7 +34,6 @@ reference: Get data from various providers contents: - tsData60UK - - tsGRDC - tsMOPEX - tsSEPA - grdcLTMMD From c92f0ea2e410c7add44876ed84b15ef688ea381a Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Tue, 28 Jun 2022 15:10:34 +0200 Subject: [PATCH 14/17] fix pkgdown --- _pkgdown.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index bfb32d3..d1ebfa9 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -44,7 +44,6 @@ reference: Utility functions, mainly used internally contents: - bboxSpatialPolygon - - getContent - title: Cached catalogues desc: > From 3d9956eb54156da1ac337cdb45ba6657b39c1ed5 Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Tue, 28 Jun 2022 15:19:49 +0200 Subject: [PATCH 15/17] simplify website --- _pkgdown.yml | 8 -------- 1 file changed, 8 deletions(-) diff --git a/_pkgdown.yml b/_pkgdown.yml index d1ebfa9..2922219 100644 --- a/_pkgdown.yml +++ b/_pkgdown.yml @@ -45,14 +45,6 @@ reference: contents: - bboxSpatialPolygon -- title: Cached catalogues - desc: > - Cached version of the output of the catalogue*() functions - contents: - - Data60UKcatalogue - - GRDCcatalogue - - MOPEXcatalogue - - SEPAcatalogue articles: - title: All articles From 767c002e10e1ccceecf2f2039ff920abd81dcfa4 Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:34:11 +0200 Subject: [PATCH 16/17] remove if(class=) statement --- R/bboxSpatialPolygon.R | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/R/bboxSpatialPolygon.R b/R/bboxSpatialPolygon.R index 8c124df..fa0d92b 100644 --- a/R/bboxSpatialPolygon.R +++ b/R/bboxSpatialPolygon.R @@ -23,7 +23,7 @@ bboxSpatialPolygon <- function(boundingbox, proj4stringFrom = NULL, proj4stringTo = NULL) { if (!is.null(proj4stringFrom)) { - stopifnot(class(sf::st_crs(proj4stringFrom)) == "crs") + stopifnot(inherits(sf::st_crs(proj4stringFrom),"crs")) } if (is.null(proj4stringFrom)) { @@ -33,7 +33,7 @@ bboxSpatialPolygon <- function(boundingbox, if(is.matrix(boundingbox)) if(dim(boundingbox)==c(2,2)) bb <- boundingbox #For compatibility with raster input bounding box objects - if(class(boundingbox) == "Extent"){ + if(inherits(boundingbox, "Extent")){ bb <- matrix(as.numeric(c( boundingbox@xmin, boundingbox@ymin, boundingbox@xmax, boundingbox@ymax @@ -42,7 +42,7 @@ bboxSpatialPolygon <- function(boundingbox, )} - if(class(boundingbox) == "SpatExtent"){ + if(inherits(boundingbox, "SpatExtent")){ bb <- matrix(as.numeric(c( boundingbox$xmin, boundingbox$ymin, boundingbox$xmax, boundingbox$ymax From a8f4cf4d9643990da53680b2a34bb197cd5ee58e Mon Sep 17 00:00:00 2001 From: Dorothea Hug Peter <12996416+dhugpeter@users.noreply.github.com> Date: Mon, 18 Jul 2022 11:34:36 +0200 Subject: [PATCH 17/17] add news about removed dependency from rgdal and raster --- DESCRIPTION | 2 +- NEWS.md | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/DESCRIPTION b/DESCRIPTION index 75a4358..ad59f26 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: hddtools Title: Hydrological Data Discovery Tools -Version: 0.9.4 +Version: 0.9.5 Authors@R: c(person(given = "Claudia", family = "Vitolo", role = c("aut"), email = "cvitolodev@gmail.com", comment = c(ORCID = "0000-0002-4252-1176")), diff --git a/NEWS.md b/NEWS.md index dc45292..d995632 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,7 @@ +# hddtools 0.9.5 + +*Removed dependency fom rgdal and raster packages + # hddtools 0.9.4 * Removed dependency from the rnrfa package