From 0f730a899549e3cebfe7b12cab060bf63dfec02e Mon Sep 17 00:00:00 2001 From: florianh Date: Fri, 5 Apr 2024 13:52:08 +0200 Subject: [PATCH] bugfix ERROR: [cellSize] source and target filename cannot be the same --- .buildlibrary | 2 +- .github/workflows/check.yaml | 4 ++-- CITATION.cff | 4 ++-- DESCRIPTION | 4 ++-- R/readLeifeld2018.R | 21 ++++++++++----------- README.md | 6 +++--- man/readLeifeld2018.Rd | 3 +-- 7 files changed, 21 insertions(+), 23 deletions(-) diff --git a/.buildlibrary b/.buildlibrary index 74dc41712..6879bda28 100644 --- a/.buildlibrary +++ b/.buildlibrary @@ -1,4 +1,4 @@ -ValidationKey: '28700343' +ValidationKey: '285577380' AutocreateReadme: yes AcceptedWarnings: - 'Warning: package ''.*'' was built under R version' diff --git a/.github/workflows/check.yaml b/.github/workflows/check.yaml index 46f518a21..0d812d913 100644 --- a/.github/workflows/check.yaml +++ b/.github/workflows/check.yaml @@ -11,7 +11,7 @@ jobs: runs-on: ubuntu-latest steps: - - uses: actions/checkout@v3 + - uses: actions/checkout@v4 - uses: r-lib/actions/setup-pandoc@v2 @@ -36,7 +36,7 @@ jobs: # gms, goxygen, GDPuc) will usually have an outdated binary version # available; by using extra-packages we get the newest version - - uses: actions/setup-python@v4 + - uses: actions/setup-python@v5 with: python-version: 3.9 diff --git a/CITATION.cff b/CITATION.cff index 2d9789a03..d8720b35c 100644 --- a/CITATION.cff +++ b/CITATION.cff @@ -2,8 +2,8 @@ cff-version: 1.2.0 message: If you use this software, please cite it using the metadata from this file. type: software title: 'mrmagpie: madrat based MAgPIE Input Data Library' -version: 1.44.9 -date-released: '2024-03-25' +version: 1.44.10 +date-released: '2024-04-05' abstract: Provides functions for MAgPIE country and cellular input data generation. authors: - family-names: Karstens diff --git a/DESCRIPTION b/DESCRIPTION index 2b8056a7c..e29b37e5b 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,8 +1,8 @@ Type: Package Package: mrmagpie Title: madrat based MAgPIE Input Data Library -Version: 1.44.9 -Date: 2024-03-25 +Version: 1.44.10 +Date: 2024-04-05 Authors@R: c( person("Kristine", "Karstens", , "karstens@pik-potsdam.de", role = c("aut", "cre")), person("Jan Philipp", "Dietrich", , "dietrich@pik-potsdam.de", role = "aut"), diff --git a/R/readLeifeld2018.R b/R/readLeifeld2018.R index ac1335946..b0f403ed1 100644 --- a/R/readLeifeld2018.R +++ b/R/readLeifeld2018.R @@ -3,26 +3,25 @@ #' @return List of magpie objects with results on cellular level, weight, unit and description. #' @author Florian Humpenoeder #' @examples -#' #' \dontrun{ -#' readSource("Leifeld2018", convert="onlycorrect") +#' readSource("Leifeld2018", convert = "onlycorrect") #' } #' @importFrom magclass as.magpie -readLeifeld2018 <- function(){ - - x <- terra::rast("Degradation_raster_homolosine_hires_rev4.tif") #"+proj=igh" - #re-project to regular grid - r <- terra::rast(res=0.5) - rp2 <- suppressWarnings(terra::project(x,r)) - #get cell area - a <- terra::cellSize(rp2[[1]], unit="ha", mask = TRUE) * 1e-6 +readLeifeld2018 <- function() { + # projection is +proj=igh + x <- terra::rast("Degradation_raster_homolosine_hires_rev4.tif") + # re-project to regular grid + r <- terra::rast(res = 0.5) + rp2 <- suppressWarnings(terra::project(x, r)) + # get cell area + a <- terra::cellSize(rp2[[1]], unit = "ha", mask = TRUE) + a <- a * 1e-6 # get spatial mapping map <- mrcommons::toolGetMappingCoord2Country(pretty = TRUE) # transform raster to magpie object x <- as.magpie(terra::extract(a, map[c("lon", "lat")])[, -1], spatial = 1) # set dimension names - #dimnames(x) <- list("x.y.iso" = paste(map$coords, map$iso, sep = "."), "t" = NULL, "data" = NULL) dimnames(x) <- list("coords" = map$coords, "t" = NULL, "d3" = NULL) return(x) diff --git a/README.md b/README.md index 6f0e77f29..b054524fc 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # madrat based MAgPIE Input Data Library -R package **mrmagpie**, version **1.44.9** +R package **mrmagpie**, version **1.44.10** [![CRAN status](https://www.r-pkg.org/badges/version/mrmagpie)](https://cran.r-project.org/package=mrmagpie) [![DOI](https://zenodo.org/badge/DOI/10.5281/zenodo.4319612.svg)](https://doi.org/10.5281/zenodo.4319612) [![R build status](https://github.com/pik-piam/mrmagpie/workflows/check/badge.svg)](https://github.com/pik-piam/mrmagpie/actions) [![codecov](https://codecov.io/gh/pik-piam/mrmagpie/branch/master/graph/badge.svg)](https://app.codecov.io/gh/pik-piam/mrmagpie) [![r-universe](https://pik-piam.r-universe.dev/badges/mrmagpie)](https://pik-piam.r-universe.dev/builds) @@ -39,7 +39,7 @@ In case of questions / problems please contact Kristine Karstens , R package version 1.44.9, . +Karstens K, Dietrich J, Chen D, Windisch M, Alves M, Beier F, Köberle A, v. Jeetze P, Mishra A, Humpenoeder F, Sauer P (2024). _mrmagpie: madrat based MAgPIE Input Data Library_. doi:10.5281/zenodo.4319612 , R package version 1.44.10, . A BibTeX entry for LaTeX users is @@ -48,7 +48,7 @@ A BibTeX entry for LaTeX users is title = {mrmagpie: madrat based MAgPIE Input Data Library}, author = {Kristine Karstens and Jan Philipp Dietrich and David Chen and Michael Windisch and Marcos Alves and Felicitas Beier and Alexandre Köberle and Patrick {v. Jeetze} and Abhijeet Mishra and Florian Humpenoeder and Pascal Sauer}, year = {2024}, - note = {R package version 1.44.9}, + note = {R package version 1.44.10}, doi = {10.5281/zenodo.4319612}, url = {https://github.com/pik-piam/mrmagpie}, } diff --git a/man/readLeifeld2018.Rd b/man/readLeifeld2018.Rd index cf614414a..2f57322a9 100644 --- a/man/readLeifeld2018.Rd +++ b/man/readLeifeld2018.Rd @@ -13,9 +13,8 @@ List of magpie objects with results on cellular level, weight, unit and descript read potential peatland area from Leifeld2018 } \examples{ - \dontrun{ - readSource("Leifeld2018", convert="onlycorrect") +readSource("Leifeld2018", convert = "onlycorrect") } } \author{