R/convertAmmoniaProductionUSGS.R

Defines functions convertAmmoniaProductionUSGS

Documented in convertAmmoniaProductionUSGS

#' @import utils
#' @import madrat

convertAmmoniaProductionUSGS <- function(x) {
  usgstomagpie <- read.csv("CountryUSGStoMAgPIE.csv", stringsAsFactors = FALSE)
  tmp <- getRegions(x)
  tmp[match(usgstomagpie$Country.USGS, tmp, nomatch = FALSE)] <- usgstomagpie$Country.MagPIE
  getRegions(x) <- tmp
  map <- toolGetMapping(type = "regional", name = "regionmappingMAgPIE.csv")

  y <- toolAggregate(x, map, partrel = T, from = 1, to = 2)
  y <- toolCountryFill(y, fill = 0)
  y[is.na(y)] <- 0

  return(y)
}
pik-piam/mrvalidnitrogen documentation built on Jan. 19, 2024, 2:16 a.m.