How to Map the World's Ports by Country and Harbor Size

On this page

Problem statement

Mapping ports by country looks like a group-by on the World Port Index's Country Code column, and the column is not a code: it holds 195 country and territory names, a third of which match no standard map's names, from "Burma" to "Caribbean Netherlands". Ports also sit on the coast, so a point-in-polygon join to generalised country outlines misses many. This page counts ports by country, shows which names fail to match, joins by nearest country instead, and compares the share of large ports between countries and continents.

Quick answer

Count ports by the country column, all ports and medium or large only:

world = gpd.read_file("data/ne_110m_admin_0_countries.zip")[["ADMIN", "CONTINENT", "geometry"]]
c = ports["Country Code"].value_counts()
print(c.head(10).to_string())
big = ports[ports["Harbor Size"].isin(["Large", "Medium"])]["Country Code"].value_counts()
print(big.head(6).to_dict())
Country Code
United States     666
Canada            285
United Kingdom    186
Japan             163
Norway            141
Indonesia         123
Italy             123
Sweden             92
Philippines        71
Denmark            69
{'United States': 59, 'Japan': 37, 'United Kingdom': 31, 'Italy': 22, 'Canada': 19, 'France': 18}

The United States has 666 ports in the index, Canada 285, the United Kingdom 186, Japan 163 and Norway 141, then Indonesia, Italy, Sweden, the Philippines and Denmark. Counting only medium and large ports, the United States still leads with 59, then Japan with 37 and the United Kingdom with 31: the long counts for Canada and Norway are mostly small harbours on long, indented coasts.

World choropleth of ports per country by nearest country, darkest for the United States and Canada, with most of Africa and inland Asia in the lightest classes. World choropleth of ports per country by nearest country, darkest for the United States and Canada, with most of Africa and inland Asia in the lightest classes.
Ports per country, by nearest country.

Names, nearest countries and large ports

1. Country names that do not match a map

unmatched = sorted(set(c.index) - set(world.ADMIN))
print(f"country values: {len(c)}; not a Natural Earth country name: {len(unmatched)}")
print(unmatched[:12])
country values: 195; not a Natural Earth country name: 71
['American Samoa', 'Antigua and Barbuda', 'Aruba', 'Bahrain', 'Barbados', 'Bermuda', 'British Indian Ocean Territory', 'British Virgin Islands', 'Burma', 'Cabo Verde', 'Caribbean Netherlands', 'Cayman Islands']

71 of the 195 country values are not a Natural Earth country name: territories such as American Samoa, Aruba and Bermuda, which the 1:110m countries do not separate, small states missing at that scale, and different spellings such as Burma for Myanmar and Cabo Verde. A join on names drops all their ports, and a lookup table is the fix if you need the index's own country.

2. Join by location instead

j = gpd.sjoin_nearest(ports.to_crs(3857), world.to_crs(3857), how="left", distance_col="m")
j = j[~j.index.duplicated()]
print(f"ports on land in a country: {(j.m == 0).sum():,}; within 10 km of one: {(j.m.between(1, 10_000)).sum():,}; median offshore distance: {j.loc[j.m > 0, 'm'].median() / 1000:.1f} km")
print((j["Country Code"] == j.ADMIN).mean().round(3))
ports on land in a country: 2,520; within 10 km of one: 575; median offshore distance: 12.9 km
0.753

Joining each port to its nearest country by distance avoids the names. 2,520 ports fall on land in a country outline and 575 within 10 km; the median offshore port is 12.9 km out, because the generalised outlines cut off headlands and islands. The nearest country agrees with the index's own country for 75.3% of ports; the rest are mostly the territories and islands that the coarse map merges or misses.

Histogram on a log scale of the distance from ports outside the generalised country outlines to the nearest outline, with a median of 12.9 kilometres. Histogram on a log scale of the distance from ports outside the generalised country outlines to the nearest outline, with a median of 12.9 kilometres.
Ports outside the 1:110m country outlines.

3. The share of large ports

share = j.groupby("ADMIN").agg(ports=("Main Port Name", "size"), large=("Harbor Size", lambda s: s.isin(["Large", "Medium"]).mean()))
print(share[share.ports >= 50].sort_values("large", ascending=False).round(3).to_string())
                          ports  large
ADMIN                                 
Spain                        50  0.340
France                       71  0.254
China                        68  0.235
Japan                       160  0.231
Australia                    66  0.212
Italy                       123  0.195
India                        55  0.164
United Kingdom              199  0.156
Russia                       81  0.136
Sweden                      101  0.129
Indonesia                   114  0.096
Turkey                       65  0.092
United States of America    662  0.092
Philippines                  72  0.083
Norway                      143  0.077
Canada                      295  0.061
Denmark                      58  0.052

Among countries with 50 or more ports, Spain has the highest share of medium and large ports, 34.0%, then France at 25.4%, China, Japan and Australia above 20%. The United States has 9.2% and Canada 6.1%, Norway 7.7% and Denmark 5.2%: the index lists many small harbours there and few elsewhere.

Ports by continent and size

The data used on this page

The US National Geospatial-Intelligence Agency's World Port Index (Pub. 150), the CSV served by its Maritime Safety Information site, downloaded on 28 October 2026 and saved on this site, because NGA revises the index as port information changes. A US government publication, free to use. Depths and lengths are in metres. Countries, land and populated places are Natural Earth's, public domain.

from pathlib import Path
import zipfile

import geopandas as gpd
import numpy as np
import pandas as pd
import requests

Path("data").mkdir(exist_ok=True)
# NGA's World Port Index (Pub. 150) as CSV, with Natural Earth's populated places, countries and land. Saved
# 28 October 2026: NGA revises the index as port information changes.
# Live: https://msi.nga.mil/api/publications/download?type=view&key=16920959/SFH00000/UpdatedPub150.csv
ARCHIVE = "nga-world-port-index-2026-10-28.zip"
if not Path(f"data/{ARCHIVE}").exists():
    Path(f"data/{ARCHIVE}").write_bytes(requests.get(f"https://data.spatialworkflow.io/{ARCHIVE}", timeout=600).content)
Z = zipfile.ZipFile(f"data/{ARCHIVE}")
for f in ["ne_10m_populated_places_simple.zip", "ne_110m_admin_0_countries.zip", "ne_50m_land.zip"]:
    Path(f"data/{f}").write_bytes(Z.read(f))
wpi = pd.read_csv(Z.open("UpdatedPub150.csv"), encoding="utf-8-sig")
wpi = wpi.replace(r"^\s*$", np.nan, regex=True)                                  # blank cells are a single space
DEPTHS = [c for c in wpi.columns if c.endswith("(m)")]
wpi[DEPTHS] = wpi[DEPTHS].where(wpi[DEPTHS] > 0)                                    # 0 means not recorded
ports = gpd.GeoDataFrame(wpi, geometry=gpd.points_from_xy(wpi.Longitude, wpi.Latitude), crs=4326)
print(f"World Port Index: {len(ports):,} ports in {ports['Country Code'].nunique()} countries and territories")
World Port Index: 3,807 ports in 195 countries and territories

Example 1: ports by continent and size

print(pd.crosstab(j.CONTINENT, j["Harbor Size"])[["Very Small", "Small", "Medium", "Large"]].to_string())
Harbor Size    Very Small  Small  Medium  Large
CONTINENT                                      
Africa                162     80      31     18
Antarctica              7      1       0      0
Asia                  443    208     101     45
Europe                555    358     131     67
North America         729    260      80     31
Oceania                87     49      10      7
South America         126     65      23      6

By continent, Europe has the most small, medium and large ports, North America the most very small ones, 729, and Asia the second most large ones, 45. Africa and South America have few ports of any size for their coastlines, which says as much about how thoroughly each coast is described as about how many ports it has.

Stacked horizontal bars of ports by continent and harbour size, Europe and North America with the most, North America the most very small ones. Stacked horizontal bars of ports by continent and harbour size, Europe and North America with the most, North America the most very small ones.
Ports by continent and harbour size.