Skip to content

danykakbyrnes/US_Phosphorus

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

219 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

United States Phosphorus Use Efficiency Analysis

The following scripts are used to recreate data and figures required for the paper titled Byrnes, D. K., Van Meter, K. J., Chang, S. Y., & Basu, N. B. (2026). Balancing Legacy and Efficiency: Present and Historical Phosphorus Management Across the United States. Global Biogeochemical Cycles. https://doi.org/10.1029/2025GB008893

The analysis of phosphorus use across the US from 1930 to 2017 using the newly published gTREND-Phosphorus dataset.

Data Source

DOI

  • gTREND-phosphorus data: Available on Figshare

Usage Instructions

In all cases, set working directory to project root. Eg:

cd /home/username/repo_root/

1. Data Generation

These scripts must be executed first to generate the required data files for subsequent analysis and figure generation. All geospatial TIF files are projected in EPSG:5070 - NAD83 / Conus Albers.

DATA_AggregatingTRENDComponents.m

  • Purpose: Moving crop uptake, livestock manure P inputs, fertilizer, and aggregating components to calculate agricultural surplus from raw gTREND data.
  • Input: gTREND data layers (annual fertilizer P input, manure P input, and crop P removal TIF files).
  • Output: Annual (1930-2017) geospatial TIF files of the components and surplus. Maps in Figure 1 are produced in QGIS.
  • Language: MATLAB

DATA_PhosphorusUseEfficiency_gridded.m

  • Purpose: Generates gridded phosphorus use efficiency (PUE) data.
  • Input: gTREND data layers (annual fertilizer P input, manure P input, and crop P removal TIF files).
  • Output: Annual (1930-2017) geospatial TIF files of PUE (ratio of crop P removal to total manure P and fertilizer P inputs). Maps in Figure 2 are produced in QGIS.
  • Language: MATLAB

DATA_CumulativePhosphorusSurplus_gridded.m

  • Purpose: Generates gridded cumulative phosphorus surplus data.
  • Input: gTREND data layers (annual fertilizer P input, manure P input, and crop P removal TIF files).
  • Output: Annual (1930-2017) geospatial TIF files of cumulative surplus (summation of manure P inputs, fertilizer P inputs, and crop P removal). Maps in Figure 7 are produced in QGIS.
  • Language: MATALB

DATA_Regional_Surplus_Components_PUE.R

  • Purpose: Extacts regional-level surplus, components, and PUE.
  • Input: gTREND components, agricultural surplus, and PUE TIF files.
  • Output: Text file of annual mean and median statistics (1930-2017) by region for P components, agricultural surplus, and PUE.
  • Language: R

DATA_Regional_CumultativeSurplus.R

  • Purpose: Extacts regional-level cumulative surplus.
  • Input: Cumulative surplus 1980 and 2017 TIF files and region shapefiles.
  • Output: Text file containing mean and median cumulative surplus statistics by region for 1980 and 2017.
  • Language: R

DATA_Regional_AgrLandUse.R

  • Purpose: Extacts regional-level agricultural land use. This script can only be run if you have the land use rasters. Otherwise you can skip this step and download required data file DOI
  • Input: Annual agricultural land use TIF text file.
  • Output: Text file (RegionLandUse_frac.txt) of percent agricultural land use (1930-2017) by region.
  • Language: R

DATA_Regional_ProportionManure_Input.R

  • Purpose: Extacts regional-level proportion of total P-input from manure inputs.
  • Input: Proportion of total input fom manure 1980 and 2017 TIF files and region shapefiles.
  • Output: Text file of percent agricultural land use (1930-2017) by region.
  • Language: R

DATA_PUE_cSurplus_quadrantsData.m

  • Purpose: Categorizes agricultural parcels for framework analysis.
  • Input: PUE and cumulative surplus TIF files for 1980 and 2017.
  • Output: Matlab file with vectorized grid-cell in 1980 and 2017.
  • Language: MATLAB

DATA_PUEcSurplus_typologyMaps.m

  • Purpose: Categorizes agricultural parcels for framework analysis.
  • Input: PUE and cumulative surplus TIF files for 1980 and 2017.
  • Output: TIF files of categorized land use parcels in 1980 and 2017. Final maps are produced in QGIS.
  • Language: MATLAB

2. Analysis Scripts

ANA_Regional_Quadrant_Distribution.py

  • Purpose: Analysis of quadrants distribution by region used in Section 3.5.
  • Input: TIF files of categorized land use parcels in 1980 and 2017.
  • Language: Python

ANA_Region1-4_CropFertilizerUse.py

ANA_Region3_Region8_PUE.py

  • Purpose: Analysis of 2017 PUE distribution in Region 3 and 8 used in Section 3.2 (Supplemental Figure 2).
  • Input: gTREND 2017 crop and pasture P removal TIF files.
  • Language: Python

3. Figure Generation

FIG_National_Timeseries_Plots.m

  • Purpose: Generates figure of national-scale statistical summaries and time series.
  • Input: Annual PUE and surplus TIF files
  • Output: Figures 1j-i and 5b - Plots showing national median, IQR, and 5th-95th percentile for PUE and surplus.
  • Language: MATLAB

FIG_PUE_ProportionManureInputs.m

  • Purpose: Generates figure of PUE versus the proportion of manure-derived phosphorus inputs.
  • Input: National TIF files and regional medians of manure P, fertilizer P, and PUE data.
  • Output: Figure 2d - PUE vs. proportion of manure-derived P inputs (hexplot or scatter plot). Using function 'hexscatter.m'.
  • Requirements: >64GB RAM for hexplot generation. Scatter plot can be used as an alternative if hexplot function cannot be run.
  • Language: MATLAB

FIG_PUE_PS_conceptualFigure.m

  • Purpose: Generates figure to showcase the relationship between surplus and PUE.
  • Input: Gridded 2017 PUE and surplus data TIF files and regional medians.
  • Output: Figure 6 - Phosphorus surplus vs. (1-PUE) plot with regional data.
  • Language: MATLAB

FIG_PUEcSurplus_frameworkQuadrants.m

  • Purpose: Generates figures for framework quadrant analysis and transitions of land parcels betwen 1980 and 2017.
  • Input: Gridded PUE and cumulative surplus TIF files and regional medians in 1980 and 2017.
  • Output: Figures 8b, 8e-f - Quadrant plots and Sankey diagram; .mat file of vectorized data. Uses function 'plotSankeyFlowChart.m'.
  • Language: MATLAB

FIG_Regional_PUE_Surp_cSURP_lollicharts.m

  • Purpose: Generates regional summary visualizations.
  • Input: Regional median data for surplus, PUE, and cumulative surplus in 1930, 1980, and 2017.
  • Output: Figures 2c, 5c, 7c - Lollipop charts of median surplus, PUE, and cumulative surplus.
  • Language: MATLAB

FIG_Regional_PUE_component_timeseries.m

  • Purpose: Generates regional time series of PUE, manure, fertilizer, and crop removal.
  • Input: Regional median PUE, component, and agricultural land use percentage data.
  • Output: Figures 3 and 4 - Time series of PUE, components and agricultural land use.
  • Language: MATLAB

FIG_PS_cumuSurplus_conceptualFigure.m

  • Purpose: Generates supplemental figure showcasing the relationship between surplus and cumulative surplus.
  • Input: Gridded 2017 surplus and cumulative surplus TIF files and regional medians.
  • Output: Supplemental Figure 3 - Phosphorus surplus vs. cumulative surplus plot
  • Language: MATLAB

FIG_Region1-4_Cropland_Pasture.py

  • Purpose: Generating figure of crop phosphorus uptake and pasture phosphorus uptake to compare regional magnitudes.
  • Input: Regional crop and pasture P uptake data in 1930, 1980, and 2017.
  • Output: Supplemental Figure 1 - Figure of P removal by crop and pasture (used in Section 3.2).
  • Language: Python

FIG_ManucriptMetrics.m

  • Purpose: Compiles all numerical metrics reported in the manuscript.
  • Input: .mat Component quadrant summary, .mat file of vectorized data .txt of region median PUE, agricultural surplus, and cumulative surplus, .mat file of vectorized data, regional quadrant .txt.
  • Output: Text file of all the statistics and metrics reported in the manucript.
  • Language: MATLAB

Cite this code

If you use this dataset or its derived indicators, please cite the accompanying paper: Byrnes, D. K., Van Meter, K. J., Chang, S. Y., & Basu, N. B. (2026). Balancing Legacy and Efficiency: Present and Historical Phosphorus Management Across the United States. Global Biogeochemical Cycles. https://doi.org/10.1029/2025GB008893

If you are specifically reusing or adapting the code, please also cite this repository: DOI

Contact

If you have any questions, please direct questions to danyka[dot]byrnes[at]proton[dot]me.