Skip to content

GRAFS plot dataset#63

Open
AliceBeckmann wants to merge 161 commits intomainfrom
alice/grafs_plot
Open

GRAFS plot dataset#63
AliceBeckmann wants to merge 161 commits intomainfrom
alice/grafs_plot

Conversation

@AliceBeckmann
Copy link
Copy Markdown
Collaborator

@AliceBeckmann AliceBeckmann commented Oct 27, 2025

TODOs:

  • Changing the <CRP_LS> label from emissions to losses in crop production (the part that was lost and not used).

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants