The hardware and bandwidth for this mirror is donated by dogado GmbH, the Webhosting and Full Service-Cloud Provider. Check out our Wordpress Tutorial.
If you wish to report a bug, or if you are interested in having us mirror your free-software or open-source project, please feel free to contact us at mirror[@]dogado.de.
Tools to estimate the carbon footprint of dairy farms.
Implements methods based on IDF (International Dairy Federation)
and IPCC guidelines for greenhouse gas accounting.
cowfootR
provides a comprehensive toolkit for
calculating carbon footprints of dairy farms following IPCC guidelines.
The package includes:
You can install the development version of cowfootR from GitHub:
# Install development version from GitHub
# install.packages("devtools")
::install_github("juanmarcosmoreno-arch/cowfootR") devtools
This is a basic example of how to calculate the carbon footprint of a single farm:
library(cowfootR)
# 1. Define system boundaries
<- set_system_boundaries("farm_gate")
boundaries
# 2. Calculate emissions by source
<- calc_emissions_enteric(
enteric n_animals = 100,
cattle_category = "dairy_cows",
boundaries = boundaries
)
<- calc_emissions_manure(
manure n_cows = 100,
boundaries = boundaries
)
<- calc_emissions_soil(
soil n_fertilizer_synthetic = 1500,
n_excreta_pasture = 5000,
area_ha = 120,
boundaries = boundaries
)
<- calc_emissions_energy(
energy diesel_l = 2000,
electricity_kwh = 5000,
boundaries = boundaries
)
<- calc_emissions_inputs(
inputs conc_kg = 1000,
fert_n_kg = 500,
boundaries = boundaries
)
# 3. Calculate total emissions
<- calc_total_emissions(enteric, manure, soil, energy, inputs)
total_emissions print(paste("Total emissions:", round(total_emissions$total_co2eq, 1), "kg CO2eq"))
# 4. Calculate intensity metrics
<- calc_intensity_litre(
milk_intensity total_emissions = total_emissions,
milk_litres = 750000,
fat = 4.0,
protein = 3.3
)print(paste("Milk intensity:", round(milk_intensity$intensity_co2eq_per_kg_fpcm, 2),
"kg CO2eq/kg FPCM"))
<- calc_intensity_area(
area_intensity total_emissions = total_emissions,
area_total_ha = 120
)print(paste("Area intensity:", round(area_intensity$intensity_per_total_ha, 1),
"kg CO2eq/ha"))
For analyzing multiple farms, use the Excel template approach:
# 1. Download and fill template
cf_download_template("my_farms_template.xlsx")
# Open the file, fill with your farm data, and save
# 2. Read data and process multiple farms
<- readxl::read_excel("my_farms_data.xlsx")
farm_data <- calc_batch(
results data = farm_data,
tier = 2,
benchmark_region = "uruguay" # optional
)
# 3. View processing summary
print(results$summary)
# 4. Export comprehensive results to Excel
export_hdc_report(results, "carbon_footprint_results.xlsx")
You can also work directly with data frames:
# Example farm data
<- data.frame(
farm_data FarmID = c("Farm_A", "Farm_B", "Farm_C"),
Year = c("2023", "2023", "2023"),
Milk_litres = c(500000, 750000, 300000),
Fat_percent = c(4.0, 3.8, 4.2),
Protein_percent = c(3.3, 3.2, 3.4),
Cows_milking = c(100, 150, 60),
Area_total_ha = c(200, 300, 120),
N_fertilizer_kg = c(2000, 3000, 1200),
Diesel_litres = c(4000, 6000, 2400),
Electricity_kWh = c(10000, 15000, 6000)
)
# Process all farms
<- calc_batch(farm_data, tier = 2)
results
# Check results for each farm
for (i in seq_along(results$farm_results)) {
<- results$farm_results[[i]]
farm if (farm$success) {
cat("Farm", farm$farm_id, ":", round(farm$emissions_total, 1), "kg CO2eq\n")
else {
} cat("Farm", farm$farm_id, ": ERROR -", farm$error, "\n")
} }
# Farm gate (direct on-farm emissions only)
<- set_system_boundaries("farm_gate")
boundaries_fg
# Cradle to farm gate (includes upstream production)
<- set_system_boundaries("cradle_to_farm_gate")
boundaries_cfg
# Use in calculations
<- calc_batch(farm_data, boundaries = boundaries_cfg) results
The package calculates multiple intensity metrics:
FarmID
: Unique farm identifierYear
: Year of data collectionMilk_litres
: Annual milk production (liters)Cows_milking
: Number of milking cowsArea_total_ha
: Total farm area (hectares)Cows_dry
, Heifers_total
,
Calves_total
, Bulls_total
Fat_percent
, Protein_percent
,
Milk_yield_kg_cow_year
MS_intake_cows_milking_kg_day
,
Ym_percent
, Concentrate_feed_kg
N_fertilizer_kg
,
N_fertilizer_organic_kg
Diesel_litres
, Electricity_kWh
,
Petrol_litres
Area_productive_ha
,
Pasture_permanent_ha
Use cf_download_template()
to get the complete column
structure.
The package includes robust error handling for batch processing:
# Process with error handling
<- calc_batch(farm_data)
results
# Check for processing errors
if (results$summary$n_farms_with_errors > 0) {
<- results$farm_results[
error_farms sapply(results$farm_results, function(x) !x$success)
]
for (farm in error_farms) {
cat("Farm", farm$farm_id, "failed:", farm$error, "\n")
} }
This package is under active development. Please report issues or suggest improvements on GitHub.
MIT License © 2025 Juan Moreno
These binaries (installable software) and packages are in development.
They may not be fully stable and should be used with caution. We make no claims about them.
Health stats visible at Monitor.