Carbon dioxide (CO2) emissions from Agriculture (Mt CO2e)

Source: worldbank.org, 03.09.2025

Year: 2023

Flag Country Value Value change, % Rank
Afghanistan Afghanistan 0.0151 -36% 97
Albania Albania 0.049 +1.03% 83
Argentina Argentina 2.41 +5.96% 14
Armenia Armenia 0.0452 +0.668% 84
Australia Australia 3.43 +3.34% 9
Austria Austria 0.0399 -5% 87
Azerbaijan Azerbaijan 0.141 +3.3% 62
Belgium Belgium 0.0296 -18% 90
Bangladesh Bangladesh 2.82 +4.86% 10
Bulgaria Bulgaria 0.792 -0.615% 33
Bosnia & Herzegovina Bosnia & Herzegovina 0.003 -21.1% 104
Belarus Belarus 0.452 -3.56% 43
Brazil Brazil 13.2 +1.92% 3
Canada Canada 3.79 +2.41% 8
Switzerland Switzerland 0.0547 +13% 82
Chile Chile 0.396 +3.77% 46
China China 15.1 -2.71% 2
Côte d’Ivoire Côte d’Ivoire 0.136 +5.59% 64
Cameroon Cameroon 0.0761 +2.28% 77
Colombia Colombia 0.64 -0.899% 36
Costa Rica Costa Rica 0.145 +0.346% 60
Cuba Cuba 0.0223 -13.6% 93
Cyprus Cyprus 0.0036 0% 102
Czechia Czechia 0.136 -7.61% 65
Germany Germany 0.566 -8.61% 38
Denmark Denmark 0.0558 -4.94% 81
Dominican Republic Dominican Republic 0.187 +1.8% 53
Algeria Algeria 0.0931 -7.82% 74
Ecuador Ecuador 0.546 +0.202% 39
Egypt Egypt 2.76 -0.947% 11
Spain Spain 0.889 -2.75% 30
Estonia Estonia 0.071 0% 79
Ethiopia Ethiopia 0.472 +8.23% 40
Finland Finland 0 108
France France 2.23 +12.4% 17
United Kingdom United Kingdom 1.44 -1.09% 24
Georgia Georgia 0.0868 +1.76% 75
Greece Greece 0.143 -3.83% 61
Guatemala Guatemala 0.443 +1% 44
Croatia Croatia 0.061 -7.85% 80
Hungary Hungary 0.173 +3.17% 56
Indonesia Indonesia 5.89 -0.362% 5
India India 30.6 +2.27% 1
Ireland Ireland 0.179 +0.847% 55
Iran Iran 1.69 +2.53% 20
Iraq Iraq 0.0369 -42.6% 88
Iceland Iceland 0.0008 +14.3% 107
Israel Israel 0.0714 -0.557% 78
Italy Italy 0.783 -2.25% 34
Jordan Jordan 0.0146 -1.35% 98
Japan Japan 0.574 -0.933% 37
Kazakhstan Kazakhstan 0.452 -1.67% 42
Kenya Kenya 0.2 +0.958% 51
Kyrgyzstan Kyrgyzstan 0.128 0% 68
South Korea South Korea 0.455 0% 41
Kuwait Kuwait 0.0031 0% 103
Lebanon Lebanon 0.0053 0% 101
Libya Libya 0.0269 -0.738% 91
Sri Lanka Sri Lanka 0.137 -13.4% 63
Lithuania Lithuania 0.415 +0.46% 45
Latvia Latvia 0.209 -0.428% 50
Morocco Morocco 0.167 -18.7% 57
Moldova Moldova 0.112 -0.532% 70
Mexico Mexico 2.65 -1.1% 12
North Macedonia North Macedonia 0.021 +0.962% 94
Mali Mali 0.155 -5.01% 59
Myanmar (Burma) Myanmar (Burma) 1.2 +10.1% 26
Mauritius Mauritius 0.0169 0% 95
Malaysia Malaysia 1.4 -1.64% 25
Nigeria Nigeria 1.68 +15% 21
Nicaragua Nicaragua 0.136 -0.658% 66
Netherlands Netherlands 0.185 +16.3% 54
Norway Norway 0.0053 0% 101
Nepal Nepal 0.258 +4.54% 48
New Zealand New Zealand 0.907 +0.332% 29
Pakistan Pakistan 5.62 +0.311% 7
Peru Peru 1.19 -3.24% 27
Philippines Philippines 1.14 -4.86% 28
Poland Poland 1.65 -1.59% 22
North Korea North Korea 0.0254 0% 92
Portugal Portugal 0.0321 -4.75% 89
Paraguay Paraguay 0.097 +10.5% 72
Qatar Qatar 0.0018 0% 106
Romania Romania 0.844 -1.31% 32
Russia Russia 5.81 -2.63% 6
Saudi Arabia Saudi Arabia 0.278 -1.94% 47
Sudan Sudan 0.08 -23.1% 76
Senegal Senegal 0.0063 -11.3% 100
El Salvador El Salvador 0.19 +1.01% 52
Slovakia Slovakia 0.13 -0.0768% 67
Slovenia Slovenia 0.0027 0% 105
Sweden Sweden 0.0153 -3.77% 96
Syria Syria 0.0404 +3.06% 86
Thailand Thailand 2.1 -2.11% 18
Tajikistan Tajikistan 0.0433 +9.9% 85
Turkmenistan Turkmenistan 0.854 -1.2% 31
Trinidad & Tobago Trinidad & Tobago 0.0094 0% 99
Tunisia Tunisia 0.165 0% 58
Turkey Turkey 2.27 +0.0573% 16
Tanzania Tanzania 0.123 -5.23% 69
Ukraine Ukraine 2.39 -13.1% 15
Uruguay Uruguay 0.661 +4.95% 35
United States United States 6.32 -0.529% 4
Uzbekistan Uzbekistan 1.77 -3.46% 19
Venezuela Venezuela 0.105 -14% 71
Vietnam Vietnam 2.63 -4.6% 13
South Africa South Africa 1.55 +9.27% 23
Zambia Zambia 0.228 +6.24% 49
Zimbabwe Zimbabwe 0.0963 -0.722% 73

                    
# Install missing packages
import sys
import subprocess

def install(package):
subprocess.check_call([sys.executable, "-m", "pip", "install", package])

# Required packages
for package in ['wbdata', 'country_converter']:
try:
__import__(package)
except ImportError:
install(package)

# Import libraries
import wbdata
import country_converter as coco
from datetime import datetime

# Define World Bank indicator code
dataset_code = 'EN.GHG.CO2.AG.MT.CE.AR5'

# Download data from World Bank API
data = wbdata.get_dataframe({dataset_code: 'value'},
date=(datetime(1960, 1, 1), datetime.today()),
parse_dates=True,
keep_levels=True).reset_index()

# Extract year
data['year'] = data['date'].dt.year

# Convert country names to ISO codes using country_converter
cc = coco.CountryConverter()
data['iso2c'] = cc.convert(names=data['country'], to='ISO2', not_found=None)
data['iso3c'] = cc.convert(names=data['country'], to='ISO3', not_found=None)

# Filter out rows where ISO codes could not be matched — likely not real countries
data = data[data['iso2c'].notna() & data['iso3c'].notna()]

# Sort for calculation
data = data.sort_values(['iso3c', 'year'])

# Calculate YoY absolute and percent change
data['value_change'] = data.groupby('iso3c')['value'].diff()
data['value_change_percent'] = data.groupby('iso3c')['value'].pct_change() * 100

# Calculate ranks (higher GDP per capita = better rank)
data['rank'] = data.groupby('year')['value'].rank(ascending=False, method='dense')

# Calculate rank change from previous year
data['rank_change'] = data.groupby('iso3c')['rank'].diff()

# Select desired columns
final_df = data[['country', 'iso2c', 'iso3c', 'year', 'value',
'value_change', 'value_change_percent', 'rank', 'rank_change']].copy()

# Optional: Add labels as metadata (could be useful for export or UI)
column_labels = {
'country': 'Country name',
'iso2c': 'ISO 2-letter country code',
'iso3c': 'ISO 3-letter country code',
'year': 'Year',
'value': 'GDP per capita (current US$)',
'value_change': 'Year-over-Year change in value',
'value_change_percent': 'Year-over-Year percent change in value',
'rank': 'Country rank by GDP per capita (higher = richer)',
'rank_change': 'Change in rank from previous year'
}

# Display first few rows
print(final_df.head(10))

# Optional: Save to CSV
#final_df.to_csv("gdp_per_capita_cleaned.csv", index=False)
                    
                
                    
# Check and install required packages
required_packages <- c("WDI", "countrycode", "dplyr")

for (pkg in required_packages) {
  if (!requireNamespace(pkg, quietly = TRUE)) {
    install.packages(pkg)
  }
}

# Load the necessary libraries
library(WDI)
library(dplyr)
library(countrycode)

# Define the dataset code (World Bank indicator code)
dataset_code <- 'EN.GHG.CO2.AG.MT.CE.AR5'

# Download data using WDI package
dat <- WDI(indicator = dataset_code)

# Filter only countries using 'is_country' from countrycode
# This uses iso2c to identify whether the entry is a recognized country
dat <- dat %>%
  filter(countrycode(iso2c, origin = 'iso2c', destination = 'country.name', warn = FALSE) %in%
           countrycode::codelist$country.name.en)

# Ensure dataset is ordered by country and year
dat <- dat %>%
  arrange(iso3c, year)

# Rename the dataset_code column to "value" for easier manipulation
dat <- dat %>%
  rename(value = !!dataset_code)

# Calculate year-over-year (YoY) change and percentage change
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(
    value_change = value - lag(value),                              # Absolute change from previous year
    value_change_percent = 100 * (value - lag(value)) / lag(value) # Percent change from previous year
  ) %>%
  ungroup()

# Calculate rank by year (higher value => higher rank)
dat <- dat %>%
  group_by(year) %>%
  mutate(rank = dense_rank(desc(value))) %>% # Rank countries by descending value
  ungroup()

# Calculate rank change (positive = moved up, negative = moved down)
dat <- dat %>%
  group_by(iso3c) %>%
  mutate(rank_change = rank - lag(rank)) %>% # Change in rank compared to previous year
  ungroup()

# Select and reorder final columns
final_data <- dat %>%
  select(
    country,
    iso2c,
    iso3c,
    year,
    value,
    value_change,
    value_change_percent,
    rank,
    rank_change
  )

# Add labels (variable descriptions)
attr(final_data$country, "label") <- "Country name"
attr(final_data$iso2c, "label") <- "ISO 2-letter country code"
attr(final_data$iso3c, "label") <- "ISO 3-letter country code"
attr(final_data$year, "label") <- "Year"
attr(final_data$value, "label") <- "GDP per capita (current US$)"
attr(final_data$value_change, "label") <- "Year-over-Year change in value"
attr(final_data$value_change_percent, "label") <- "Year-over-Year percent change in value"
attr(final_data$rank, "label") <- "Country rank by GDP per capita (higher = richer)"
attr(final_data$rank_change, "label") <- "Change in rank from previous year"

# Print the first few rows of the final dataset
print(head(final_data, 10))