R/getWorldBankClimateData.R

Defines functions getWorldBankClimateData

Documented in getWorldBankClimateData

##' Get World Bank Climate Data
##' 
##' <DESCRIPTION>
##' 
##' @export

getWorldBankClimateData = function(){
    ## allCountries =
    ##     GetCodeList(domain = "WorldBank",
    ##                 dataset = "wb_ecogrw",
    ##                 dimension = "geographicAreaM49")[type == "country", code]
    
    newKey =
        DatasetKey(domain = "WorldBank",
                   dataset = "wb_climate",
                   dimensions =
                       list(
                           Dimension(name = "geographicAreaM49",
                                     keys = getAllCountries()),
                           Dimension(name = "wbIndicator",
                                     keys = c("SWS.FAO.PREC", "SWS.FAO.TEMP")),
                           Dimension(name = "timePointYears",
                                     keys = getAllYears())
                       )
                   )

    newPivot = c(
        Pivoting(code = "geographicAreaM49", ascending = TRUE),
        Pivoting(code = "timePointYears", ascending = FALSE),
        Pivoting(code = "wbIndicator", ascending = TRUE)        
    )

    climateData = GetData(key = newKey, pivoting = newPivot, normalized = FALSE,
                          flags = FALSE) # No flags in this dataset
    climateData[, timePointYears := as.numeric(timePointYears)]
    climateData
}
SWS-Methodology/faoswsSeed documentation built on Nov. 21, 2020, 5:43 p.m.