Package 'mrfaocore'

Title: madrat-based package providing core FAO-related preprocessing functions
Description: This madrat-based package provides core FAO-related preprocessing functions.
Authors: David Chen [aut, cre], Ulrich Kreidenweis [aut], Abhijeet Mishra [aut], Kristine Karstens [aut], Benjamin Leon Bodirsky [aut], Debbora Leip [aut], Mishko Stevanovic [aut], Benjamin Leon Bodrisky [aut], David Klein [aut], Edna Molina Bacca [aut]
Maintainer: David Chen <[email protected]>
License: LGPL-3
Version: 1.1.1
Built: 2024-12-13 05:59:20 UTC
Source: https://github.com/pik-piam/mrfaocore

Help Index


calcAttributes

Description

provides attributes of different products

Usage

calcAttributes(subtype = "Products")

Arguments

subtype

subtype of readProductAttributes function.

Value

List of magpie objects with results on global level, empty weight, unit and description.

Author(s)

Benjamin Leon Bodirsky

See Also

[readProductAttributes()]

Examples

## Not run: 
calcOutput("Attributes")

## End(Not run)

calcFAOBilateralTrade

Description

Calculates bilateral trade values based on FAO trade matrix

Usage

calcFAOBilateralTrade(
  output = "value",
  products = "kcr",
  prodAgg = TRUE,
  fiveYear = TRUE
)

Arguments

output

"value", "qty", or "price"

products

"kcr", "kli", or "kothers"

prodAgg

binary to keep FAO product level or magpie

fiveYear

only 5 year steps due to memory load

Value

List of magpie objects with results on bilateral country level, weight on bilateral country level, unit and description.

Author(s)

David M Chen

Examples

## Not run: 
calcOutput("FAOBilateralTrade", output = "qty", products = "kcr")

## End(Not run)

calcFAOharmonized

Description

Calculate harmonized FAO Commodity Balance and Food Supply data based on CB, only harvested areas are taken from ProdSTAT. This functions adds the CBCrop, CBLive, FSCrop and FSLive data together.

Usage

calcFAOharmonized()

Value

FAO harmonized data, weight as NULL, and a description as as a list of MAgPIE objects

Author(s)

Ulrich Kreidenweis, David Chen, Kristine Karstens

Examples

## Not run: 
a <- calcOutput("FAOharmonized")

## End(Not run)

calcFAOLand

Description

Returns physical land areas from FAOSTAT

Usage

calcFAOLand()

Value

land areas from FAOSTAT and weight

Author(s)

Ulrich Kreidenweis, Kristine Karstens


calcFAOmassbalance_pre

Description

Calculates an extended version of the Food Balance Sheets. Makes explicit the conversion processes that convert one type of product into another. Includes processes like milling, distilling, extraction etc. Adds certain byproducts like distillers grains or ethanol.

Usage

calcFAOmassbalance_pre(years = NULL)

Arguments

years

years to be estimated, if null, then all years in FAOharmonized are returned

Value

List of magpie objects with results on country level, weight on country level, unit and description. This is an intermediary result, which is used e.g. for estimating the feed baskets. For most uses, it is more appropriate to use the FAOmasbalance instead of the FAOmassbalance_pre.

Author(s)

Benjamin Leon Bodirsky

See Also

[calcFAOmassbalance()]

Examples

## Not run: 
calcOutput("FAOmassbalance_pre")

## End(Not run)

calcFAOTradePrices

Description

calculates USD per kg of FAOSTAT Trade data for import and export prices

Usage

calcFAOTradePrices(aggregation = "k")

Arguments

aggregation

"none", "k", "fbs" or "springmann" for the last uses Marco Springmann's custom product mapping

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

David M Chen

Examples

## Not run: 
calcOutput("calcFAOTradePrices")

## End(Not run)

calcFertilizerPricesFAO

Description

calculates dataset of fertilizer prices in US$MER17/tonne (either referring to the amount of fertilizer product, or to the amount of nutrients within the fertilizer) based on FAO data

Usage

calcFertilizerPricesFAO(subtype = "N", by = "nutrient")

Arguments

subtype

"N" for fertilizer containing nitrogen, "P" for fertilizer containing phosphorus

by

"nutrient" if referring to price per amount of nutrients (N or P) within the fertilizer products, or "product" if referring to price per amount of fertilizer product

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("FertilizerPricesFAO", subtype = "N", by = "nutrient")

## End(Not run)

calcFertilizerUseFAO

Description

calculates dataset of fertilizer use in tonnes (either referring to the amount of fertilizer products used, or to the amount of nutrients within the fertilizer used) based on FAO data

Usage

calcFertilizerUseFAO(subtype = "N", by = "nutrient")

Arguments

subtype

"N" for fertilizer containing nitrogen, "P" for fertilizer containing phosphorus (note that there is an overlap between those categories, as some fertilizers include both nutrients)

by

"nutrient" if referring to amount of nutrients (N or P) in total used fertilizer, or "product" if referring to total amount of fertilizer used

Value

List of magpie objects with results on country level, weight on country level, unit and description.

Author(s)

Debbora Leip

Examples

## Not run: 
calcOutput("FertilizerUseFAO", subtype = "N", by = "nutrient")

## End(Not run)

Convert FAO data

Description

Converts FAO data to fit to the common country list and removes or converts relative values where possible. Yields (Hg/ha) are for instance removed since they can later easily be calculated from production and area but might be problematic in the spatial aggregation. Per capita demand values are transformed into absolute values using population estimates from the calcPopulationPast function.

Usage

convertFAO(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO file type, e.g.: CBCrop

Details

Update 23-Jan-2017 - Added FAO Forestry production and trade data (Abhi)

Value

Data as MAgPIE object with common country list

Author(s)

Ulrich Kreidenweis, Abhijeet Mishra, Mishko Stevanovic

See Also

[readFAO()], [readSource()],

Examples

## Not run: 
a <- readSource("FAO", "Crop", convert = TRUE)

## End(Not run)

Convert FRA 2015 data Update dd-Jmm-jjjj - Please add comment if changes made here (Abhi)

Description

Convert FRA 2015 data Update dd-Jmm-jjjj - Please add comment if changes made here (Abhi)

Usage

convertFAO_FRA2015(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO FRA 2015 file type, e.g.: fac, production, biodiversity or anndat.

Value

Data as MAgPIE object with common country list

Author(s)

Abhijeet Mishra

See Also

[readSource()],

Examples

## Not run: 
a <- readSource("FRA2015", "production", convert = TRUE)

## End(Not run)

Convert FAO data

Description

Converts FAO data to fit to the common country list and removes or converts relative values where possible. Yields (Hg/ha) are for instance removed since they can later easily be calculated from production and area but might be problematic in the spatial aggregation. Per capita demand values are transformed into absolute values using population estimates from the calcPopulationPast function.

Usage

convertFAO_online(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO file type, e.g.: CBCrop

Details

Update 23-Jan-2017 - Added FAO Forestry production and trade data (Abhi)

Value

Data as MAgPIE object with common country list

Author(s)

Ulrich Kreidenweis, Abhijeet Mishra, Mishko Stevanovic, David Klein, Daivd Chen, Edna Molina Bacca

See Also

[readFAO()], [readSource()],

Examples

## Not run: 
a <- readSource("FAO_online", "Crop", convert = TRUE)

## End(Not run)

Convert FAOTradeMatrix

Description

Convert FAOSTAT detailed trade matrix. FAOSTAT does not balance or harmonize the import/export side reporting. Furthermore, in terms of trade value, exporters are "usuallY" reporting FOB, while importers report CIF. Difference in value, given identical qty, is thus the transport margin mixed with unharmonized reporting.

Usage

convertFAOTradeMatrix(x, subtype)

Arguments

x

output from read function

subtype

subsets of the detailed trade matrix to read in. Very large csv needs to be read in chunks separated by export/import quantities and values, as well as kcr, kli and kothers (not in kcr nor kli) Options are all combinations of c("import_value", "import_qty", "export_value", "export_quantity") X c("kcr", "kli", "kothers")) import is import side reporting while export is export-sde reporting

Value

FAO data as MAgPIE object in Mt or US$ 2017

Author(s)

David C

See Also

[readSource()]


Convert FRA 2020 data

Description

Convert FRA 2020 data

Usage

convertFRA2020(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO FRA 2020 subtype.

Value

Data as MAgPIE object with common country list

Author(s)

Abhijeet Mishra

See Also

[readSource()],

Examples

## Not run: 
a <- readSource("FRA2020", "growing_stock", convert = TRUE)

## End(Not run)

correctFAO

Description

Corrects FAO data for known mismatches or insufficiencies

Usage

correctFAO(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO file type, e.g.: CBCrop

Value

Data as MAgPIE object

Author(s)

Kristine Karstens

See Also

[readFAO()], [readSource()],

Examples

## Not run: 
a <- readSource("FAO", "Crop", convert = TRUE)

## End(Not run)

correctFAO_online

Description

Corrects FAO data for known mismatches or insufficiencies

Usage

correctFAO_online(x, subtype)

Arguments

x

MAgPIE object containing original values

subtype

The FAO file type, e.g.: CBCrop

Value

Data as MAgPIE object

Author(s)

Kristine Karstens

See Also

[readFAO()], [readSource()],

Examples

## Not run: 
a <- readSource("FAO_online", "Crop", convert = TRUE)

## End(Not run)

Download FAO data

Description

Downloads the latest data and meta data form the FAOStat website.

Usage

downloadFAO_online(subtype)

Arguments

subtype

Type of FAO data that should be read.


Read FAO

Description

Read in FAO data that has been bulk downloaded from the FAOSTAT website. Files with exception of fodder.csv are aquired from: http://faostat.fao.org/Portals/_Faostat/Downloads/zip_files/

Usage

readFAO(subtype)

Arguments

subtype

Type of FAO data that should be read. Available types are:

  • 'CBCrop': Commodity Balance Crop (CommodityBalances_Crops_E_All_Data.zip)

  • 'CBLive': Commoditiy Balance Livestock (CommodityBalances_LivestockFish_E_All_Data.zip)

  • 'Crop': Production Crops ("Production_Crops_E_All_Data.zip")

  • 'CropProc': Production Crops Processed ("Production_CropsProcessed_E_All_Data.zip")

  • 'Fbs': Food Balance Sheet ("FoodBalanceSheets_E_All_Data.zip")

  • 'Fertilizer': Fertilizer ("Resources_Fertilizers_E_All_Data.zip")

  • 'Fodder': Fodder (data that has been manually downloaded from the FAOSTAT website as seperate .xls files via a search for "forage" and "fodder" withing Production-Crops. These datasets have been added together to a "Fodder.csv" file)

  • 'FoodSecurity': Food Security Data ("Food_Security_Data_E_All_Data.zip")

  • 'FSCrop': Food Supply Crops ("FoodSupply_Crops_E_All_Data.zip")

  • 'FSLive': Food Supply Livestock ("FoodSupply_LivestockFish_E_All_Data.zip")

  • 'Land': Land ("Resources_Land_E_All_Data.zip")

  • 'LiveHead': Production Live Animals ("Production_Livestock_E_All_Data.zip")

  • 'LivePrim': Production Livestock Primary ("Production_LivestockPrimary_E_All_Data.zip")

  • 'LiveProc': Production Livestock Processed ("Production_LivestockProcessed_E_All_Data.zip")

  • 'Pop': Population ("Population_E_All_Data.zip")

  • 'ForestProdTrade': Forestry Production and Trade ("Forestry_E_All_Data_(Normalized).zip")

  • 'PricesProducerAnnual': Producer Prices - Annual ("Prices_E_All_Data.zip")

  • 'PricesProducerAnnualLCU': Producer Prices - Annual in LCU ("Prices_E_All_Data.zip")

  • 'ValueOfProd': Value of Agricultural Production ("Value_of_Production_E_All_Data.zip")

Details

Update 23-Jan-2017 - Added FAO Forestry production and trade data (Abhi)

Value

FAO data as MAgPIE object

Author(s)

Ulrich Kreidenweis, Abhijeet Mishra, Mishko Stevanovic

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FAO", "Crop")

## End(Not run)

Read FAO_FRA2015

Description

Read-in an FRA data from 2015 (forest resource assessment)

Usage

readFAO_FRA2015(subtype)

Arguments

subtype

data subtype. Either "production" or "fac" (forest area and characteristics) or "biodiversity" or "anndat" (Annual Data)

Value

magpie object of the FRA 2015 data

Author(s)

Abhijeet Mishra

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FAO_FRA2015", "production")

## End(Not run)

Read FAO_online

Description

Read in FAO data that has been downloaded from the FAOSTAT website. Files with exception of fodder.csv are aquired according to downloadFAO.

Usage

readFAO_online(subtype)

Arguments

subtype

Type of FAO data that should be read. Available types are:

  • 'CBCrop': Commodity Balance Crop (CommodityBalances_Crops_E_All_Data.zip)

  • 'CBLive': Commoditiy Balance Livestock (CommodityBalances_LivestockFish_E_All_Data.zip)

  • 'Crop': Production Crops ("Production_Crops_E_All_Data.zip")

  • 'CropProc': Production Crops Processed ("Production_CropsProcessed_E_All_Data.zip")

  • 'Fbs': Food Balance Sheet ("FoodBalanceSheets_E_All_Data.zip")

  • 'Fertilizer': Fertilizer ("Resources_Fertilizers_E_All_Data.zip")

  • 'FertilizerProducts': Fertilizer by product ("Inputs_FertilizersProduct_E_All_Data_(Normalized).zip")

  • 'FertilizerNutrients': Fertilizer by nutrient ("Inputs_FertilizersNutrient_E_All_Data_(Normalized).zip")

  • 'Fodder': Fodder (data that has been manually downloaded from the FAOSTAT website as seperate .xls files via a search for "forage" and "fodder" withing Production-Crops. These datasets have been added together to a "Fodder.csv" file)

  • 'FoodSecurity': Food Security Data ("Food_Security_Data_E_All_Data.zip")

  • 'FSCrop': Food Supply Crops ("FoodSupply_Crops_E_All_Data.zip")

  • 'FSLive': Food Supply Livestock ("FoodSupply_LivestockFish_E_All_Data.zip")

  • 'Land': Land ("Resources_Land_E_All_Data.zip")

  • 'LiveHead': Production Live Animals ("Production_Livestock_E_All_Data.zip")

  • 'LivePrim': Production Livestock Primary ("Production_LivestockPrimary_E_All_Data.zip")

  • 'LiveProc': Production Livestock Processed ("Production_LivestockProcessed_E_All_Data.zip")

  • 'Pop': Population ("Population_E_All_Data.zip")

  • 'ForestProdTrade': Forestry Production and Trade ("Forestry_E_All_Data_(Normalized).zip")

  • 'PricesProducerAnnual': Producer Prices - Annual ("Prices_E_All_Data.zip")

  • 'PricesProducerAnnualLCU': Producer Prices - Annual in LCU ("Prices_E_All_Data.zip")

  • 'ValueOfProd': Value of Agricultural Production ("Value_of_Production_E_All_Data.zip")

  • 'ValueShares': Value shares by industry and primary factors

  • 'Trade': Trade quantities and values

Details

Update 23-Jan-2017 - Added FAO Forestry production and trade data (Abhi)

Value

FAO data as MAgPIE object

Author(s)

Ulrich Kreidenweis, Abhijeet Mishra, Mishko Stevanovic, David Klein, Edna Molina Bacca

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FAO_online", "Crop")

## End(Not run)

Read parameters of Schofield equations

Description

Food and Agriculture Organization of the United Nations, World Health Organization, and United Nations University. 1985. "Energy and protein requirements." http://www.who.int/iris/handle/10665/39527.

Usage

readFAO_WHO_UNU1985()

Value

MAgPIE object

Author(s)

Benjamin Bodirsky

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("Schofield")

## End(Not run)

Read FAOTradeMatrix

Description

Read in FAOSTAT detail trade matrix. FAOSTAT does not balance or harmonize the import/export side reporting. Furthermore, in terms of trade value, exporters are "usuallY" reporting FOB, while importers report CIF. Difference in value, given identical qty, is thus the transport margin and any unharmonized reporting combined.

Usage

readFAOTradeMatrix(subtype)

Arguments

subtype

subsets of the detailed trade matrix to read in. Very large csv needs to be read in chunks separated by export/import quantities and values, as well as kcr, kli and kothers (not in kcr nor kli) Options are all combinations of c("import_value", "import_qty", "export_value", "export_quantity" X c("kcr", "kli", "kothers")) import is import side reporting while export is export-sde reporting

Value

FAO data as MAgPIE object

Author(s)

David C

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FAOTradeMatrix", "import_value_kcr")

## End(Not run)

readFishstatJ_FAO

Description

Reads data of fisheries generated using the FishstatJ app of FAO. Read-in specifically, exports_value, exports_quantity, and/or overall production of fish/aquatic products.

Usage

readFishstatJ_FAO(subtype = "Production")

Arguments

subtype

data subtype needed. Either "exportsValue", "exportsQuantity", or "Production"

Value

magpie object of either tonnes of liveweight or 1000 current USD

Author(s)

Edna J. Molina Bacca

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FishstatJ_FAO", "Production")
a <- readSource("FishstatJ_FAO", "exportsQuantity")
a <- readSource("FishstatJ_FAO", "exportsValue")

## End(Not run)

Read FRA2020

Description

Read-in an FRA (forest resource assessment) dataset from 2020.

Usage

readFRA2020(subtype)

Arguments

subtype

data subtype. Available subtypes: forest_area, deforestation, growing_stock, biomass_stock, carbon_stock, management, disturbance, forest_fire

Value

Magpie object of the FRA 2020 data

Author(s)

Abhijeet Mishra

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("FRA2020", "growing_stock")

## End(Not run)

Read product attributes

Description

Read-in a file containing the attributes of MAgPIE products. Currently Covers dry matter (DM), reactive nitrogen (Nr), Phosphorus (P), Generalizable Energy (GE) and wet matter (WM). Values are assembled from various literature sources, and the weighting and allocation is done in the spreadsheet crop_specifications_06_2011.ods and livestock_specifications_2012_06_14.ods in the svn folder /tools/Nutrients . Values standardized on DM.

Usage

readProductAttributes(subtype = "Products")

Arguments

subtype

Available subtypes: "Products", MAgPIE products "AgResidues" Aboveground crop residues and "BgResidues" Belowground crop residues

Value

magpie object with the dimension crops and attributes

Author(s)

Benjamin Leon Bodrisky

See Also

[readSource()]

Examples

## Not run: 
a <- readSource("ProductAttributes")

## End(Not run)

toolExtrapolateFodder

Description

Extrapolate fodder data, based on two time steps (5-averages around this years)

Usage

toolExtrapolateFodder(x, exyears = c(2004, 2009), average = 5, endyear = 2015)

Arguments

x

input data

exyears

two years

average

the averaging_range in toolTimeInterpolate

endyear

year till when it should be extrapolated

Value

magpie object including extrapolated years

Author(s)

Kristine Karstens


Combine FAO datasets

Description

Allows to combine two similar FAO datasets with dublicates being removed. For instance combine Production:Crops and Production: Crops Processed to one magpie object

Usage

toolFAOcombine(..., combine = "Item")

Arguments

...

two magpie objects with FAO data

combine

"Item" to combine datasets that for instance both contain palm oil data

Value

MAgPIE object with data from both inputs but dublicates removed

Author(s)

Ulrich Kreidenweis

See Also

[readSource()]

Examples

## Not run: 
a <- toolFAOcombine(Crop, CropPro, combine = "Item")

## End(Not run)