DataBrighten

    Rail lines (total route-km)

    2,139 × 6rows × columns: 116 countries, 1995 to 2021

    Real data: World Bank, World Development Indicators, indicator IS.RRS.TOTL.KM, retrieved 19 November 2026. Values are as published; we only reshaped the file.

    textnumberdateyes/no
    Rows2,139country-year values
    Countries116with at least one value
    Years1995 – 202127 years with data
    LicenceCC BY 4.0credit the World Bank

    What it measures

    The total length of rail line in the country operated for passenger transport, goods transport, or both.

    Limits and exceptions (World Bank note)

    Data for transport sectors are not always internationally comparable. Unlike for demographic statistics, national income accounts, and international trade data, the collection of infrastructure data has not been "internationalized". The data from UIC is based on voluntary reporting by railway companies, and can show drastic increases or decreases for some of the years due to lack of reporting by some of the companies in that country.

    The numbers in 2021

    In 2021, 65 countries have a value. The highest is United States (148,553); the lowest is Hong Kong SAR, China (230.1). The median country value is 3,159.

    Top 10 countries, 2021

    total route-km

    Source: World Bank, IS.RRS.TOTL.KM, retrieved 19 November 2026. Computed from rail-lines-total-route-km.csv.

    Highest, 2021

    #CountryValue
    1United States148,553
    2China109,767
    3Russian Federation85,544
    4India68,103
    5Canada48,150
    6Germany33,401
    7France27,716
    8South Africa20,953
    9Poland18,620
    10Italy17,305

    Lowest, 2021

    #CountryValue
    1Hong Kong SAR, China230.1
    2Luxembourg271
    3United Arab Emirates279
    4Kyrgyz Republic417
    5Burkina Faso518
    6Tajikistan620
    7Cote d'Ivoire639
    8Gabon648
    9Madagascar673
    10North Macedonia683
    How many countries report, by decade
    DecadeMost countries in one year
    1990s98
    2000s92
    2010s78
    2020s66

    First rows

    rail-lines-total-route-km.csv

    countrytextiso3textregiontextincome_grouptextyearnumbervaluenumber
    AlbaniaALBEurope & Central AsiaUpper middle income1995674
    AlbaniaALBEurope & Central AsiaUpper middle income1996447
    AlbaniaALBEurope & Central AsiaUpper middle income1997447
    AlbaniaALBEurope & Central AsiaUpper middle income1998447
    AlbaniaALBEurope & Central AsiaUpper middle income1999440
    AlbaniaALBEurope & Central AsiaUpper middle income2000440
    AlbaniaALBEurope & Central AsiaUpper middle income2001447
    AlbaniaALBEurope & Central AsiaUpper middle income2002447

    Data dictionary

    ColumnTypeMeaning
    countrytextCountry or economy, World Bank name
    iso3textISO 3166-1 alpha-3 code
    regiontextWorld Bank region
    income_grouptextWorld Bank income group
    yearnumberCalendar year of the value
    valuenumberRail lines (total route-km), exactly as the World Bank API returns it (not rounded)

    Only country-years with a value are in the long file; blank cells in the wide file mean no value was published.

    Practice questions

    answers computed from the file

    Which country has the highest value in 2021?

    United States, with 148,553.

    Excel (on the long CSV: E = year, F = value)

    =FILTER(A2:A100000,(E2:E100000=2021)*(F2:F100000=MAXIFS(F2:F100000,E2:E100000,2021)))

    SQL (table wb = the CSV)

    SELECT country, value FROM wb WHERE year = 2021
      AND value = (SELECT MAX(value) FROM wb WHERE year = 2021);

    pandas (df = pd.read_csv("rail-lines-total-route-km.csv"))

    y = df[df.year == 2021]
    y[y.value == y.value.max()][["country", "value"]]

    File: rail-lines-total-route-km.csv

    How many countries report a value for 2021?

    65 of the 217 economies in the file's country list.

    Excel (on the long CSV: E = year, F = value)

    =COUNTIF(E2:E100000,2021)

    SQL (table wb = the CSV)

    SELECT COUNT(*) FROM wb WHERE year = 2021;

    pandas (df = pd.read_csv("rail-lines-total-route-km.csv"))

    (df.year == 2021).sum()

    File: rail-lines-total-route-km.csv

    What is the median across countries in 2021?

    3,159 (median of the 65 country values; not a World Bank aggregate).

    Excel (on the long CSV: E = year, F = value)

    =MEDIAN(FILTER(F2:F100000,E2:E100000=2021))

    SQL (table wb = the CSV)

    -- SQLite has no MEDIAN(); this picks the middle value(s)
    SELECT AVG(value) FROM (SELECT value FROM wb WHERE year = 2021 ORDER BY value
      LIMIT 2 - (SELECT COUNT(*) FROM wb WHERE year = 2021) % 2
      OFFSET (SELECT (COUNT(*) - 1) / 2 FROM wb WHERE year = 2021));

    pandas (df = pd.read_csv("rail-lines-total-route-km.csv"))

    df[df.year == 2021]["value"].median()

    File: rail-lines-total-route-km.csv

    Which country rose the most between 2011 and 2021?

    China: from 72,487 to 109,767, a rise of 37,280 (out of 52 countries with both years).

    Excel (on the long CSV: E = year, F = value)

    Use the wide file (rail-lines-total-route-km-wide.csv): add a column = [2021] - [2011], then sort it largest to smallest.

    SQL (table wb = the CSV)

    SELECT a.country, b.value - a.value AS rise FROM wb a JOIN wb b ON a.iso3 = b.iso3
    WHERE a.year = 2011 AND b.year = 2021 ORDER BY rise DESC LIMIT 1;

    pandas (df = pd.read_csv("rail-lines-total-route-km.csv"))

    w = df.pivot(index="country", columns="year", values="value")
    (w[2021] - w[2011]).dropna().nlargest(1)

    File: rail-lines-total-route-km.csv

    Which year has the most countries reporting?

    1999, with 98 countries. (Later years are still filling in as countries report.)

    Excel (on the long CSV: E = year, F = value)

    Make a pivot table: year in Rows, Count of value in Values, then sort by the count.

    SQL (table wb = the CSV)

    SELECT year, COUNT(*) AS n FROM wb GROUP BY year ORDER BY n DESC, year DESC LIMIT 1;

    pandas (df = pd.read_csv("rail-lines-total-route-km.csv"))

    df.groupby("year").size().sort_values(ascending=False).head(1)

    File: rail-lines-total-route-km.csv