Skip to content

Commit

Permalink
bugfix ERROR: [cellSize] source and target filename cannot be the same
Browse files Browse the repository at this point in the history
  • Loading branch information
flohump committed Apr 5, 2024
1 parent 1fa1e78 commit 0f730a8
Show file tree
Hide file tree
Showing 7 changed files with 21 additions and 23 deletions.
2 changes: 1 addition & 1 deletion .buildlibrary
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
ValidationKey: '28700343'
ValidationKey: '285577380'
AutocreateReadme: yes
AcceptedWarnings:
- 'Warning: package ''.*'' was built under R version'
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/check.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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

Expand Down
4 changes: 2 additions & 2 deletions CITATION.cff
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -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", , "[email protected]", role = c("aut", "cre")),
person("Jan Philipp", "Dietrich", , "[email protected]", role = "aut"),
Expand Down
21 changes: 10 additions & 11 deletions R/readLeifeld2018.R
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -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)

Expand Down Expand Up @@ -39,7 +39,7 @@ In case of questions / problems please contact Kristine Karstens <karstens@pik-p

To cite package **mrmagpie** in publications use:

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 <https://doi.org/10.5281/zenodo.4319612>, R package version 1.44.9, <https://github.com/pik-piam/mrmagpie>.
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 <https://doi.org/10.5281/zenodo.4319612>, R package version 1.44.10, <https://github.com/pik-piam/mrmagpie>.

A BibTeX entry for LaTeX users is

Expand All @@ -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},
}
Expand Down
3 changes: 1 addition & 2 deletions man/readLeifeld2018.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 0f730a8

Please sign in to comment.