Open
Conversation
…into alice/grafs_plot
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
TODOs:
GRAFS plot dataset description
This PR introduces the main function
create_grafs_plot_df(), which includes helper functions to generate a dataset of nitrogen (MgN) flows by province and year as well as land use information in Spain. The data are assigned to labels, defined by Alfredo Rodriguez, which are needed to create GRAFS plots with Alfredo’s R package.The resulting tibble is designed to feed directly into the GRAFS visualization R package.
Label description
Land use and land N production
Land use areas and associated N production are taken from n_balance_ygpit_all.
They are aggregated by province and year and mapped to labels such as:
cropland N and area ({ARAiN}, {ARArN}, {ARAiha}, {ARArha}),
permanent crops ({PERiN}, {PERrN}),
horticulture ({HORiN}, {HORrN}),
forest and semi-natural systems ({FORN}),
grassland ({HAGRASS}, {GRASSMha})
greenhouse systems ({GREHN}).
Both irrigated and rainfed systems are treated separately.
Crop and grass N consumption
N flows (consumption) from cropland and grassland are taken from create_n_prov_destiny() and tranformed to labels including:
crops to population ({CROPS_TO_POP}),
crops to livestock ({CROPS_TO_LIVESTOCK}),
grass to livestock ({GRASS_TO_LIVESTOCK}),
crop exports ({CROP_EXPORT}),
crop N used for other uses ({CRP_OTHUSES}).
Livestock production
Livestock N production is taken from create_n_prov_destiny() and livestock_prod_ygps.
It is separated into edible and non-edible products and mapped to:
edible livestock products ({LV_EDBL}),
non-edible livestock products ({LVSTCK_NOEDIBLE}),
milk and dairy products ({LVST_MILK}),
exported livestock products ({LIVESTOCK_EXPORTED}).
Livestock losses and totals
Livestock N losses are taken from n_excretion_ygs and population-related other uses.
They are represented using the labels:
livestock losses ({AN_LS}),
livestock other uses ({AN_OTH}),
total livestock losses ({AN_LS_OTH}),
total livestock N ({LVSTCKTOTN}),
gaseous N losses ({LIVGASLOSS}).
Feed and internal transfers
Feed flows from cropland to livestock are taken from create_n_prov_destiny() and split into:
ruminant feed ({RCRTOLVSTCK_R}),
monogastric feed ({MCRTOLVSTCK_M}).
Imports and N soil inputs
N imports and N soil inputs are taken from create_n_prov_destiny() and n_balance_ygpit_all.
They are mapped to labels such as:
crop and animal product imports ({CROP_POPIMPORT}, {IMANOT}, {IMPORT_ANIMALCR}),
synthetic fertilizers ({SYNTHF}, {SYNTHF_TOTAL}),
biological fixation and atmospheric deposition ({FIXCR}, {OXDEPCROPS}, {FIX_DEP_CR}, {FIX_DEP_GRASS}),
wastewater inputs from population ({WASTEWATER}).
Livestock units and population
Livestock units (LU) are calculated from livestock_prod_ygps stock numbers and included using:
ruminant LU ({RUMIANTSLU}, {RUMIANTSMLU}),
monogastric LU ({MONOGLU}, {MONOGMLU}).
Population data are taken from population_yg and included as {POPULATIONM}.
Final steps
All datasets are merged into a single standardized table.
Missing labels required for plotting are added with zero values.