The United Nations Code for Trade and Transport Locations is a code list mantained by UNECE, United Nations agency, to facilitate trade.
Data comes from the UNECE page, released at least once a yea...
Main UN/LOCODE codelist. Each row is a location entry identified by a 2-letter country code and a 3-character location code. Rows with an empty Location field are country-name header rows or alias rows and are excluded from this file.
Field
Type
Description
Pattern
Change
string
+ (newly added); X (to be removed); | (changed); # (name changed); = (reference entry); ! (US location with duplicate IATA code)
Country
string
ISO 3166 alpha-2 country code. Defined in country-codes.csv.
[A-Z]{2}
Location
string
3-character location code (letters and digits 2–9). Combined with Country it forms the full 5-character UN/LOCODE.
[A-Z2-9]{3}
Name
string
Official name of the location, may include diacritics.
NameWoDiacritics
string
Name of the location with diacritics replaced by their ASCII equivalents.
Subdivision
string
ISO 3166-2 subdivision code for the location. Defined in subdivision-codes.csv. May be empty.
Status
string
Approval/verification status of the entry. Defined in status-indicators.csv.
Function
string
8-character function classifier string indicating which transport functions the location serves. Each position corresponds to a function code defined in function-classifiers.csv; a digit means the function is present, a dash means absent.
[01-][2-][3-][4-][5-][6-][7-][B-]
Date
string
Edition date in YYMM format (2-digit year + 2-digit month, e.g. 0601 = June 2006, 1407 = July 2014). May be empty for some entries.
[0-9]{4}
IATA
string
IATA airport code, present only when it differs from the UN/LOCODE location code. May be empty.
Coordinates
string
Geographic coordinates in DDMM[N/S] DDDMM[W/E] format (degrees and minutes). May be empty.
[0-9]{4}[NS] [0-9]{5}[WE]
Remarks
string
Free-text remarks or notes about the location entry. May be empty.
country-codes
Lookup table mapping ISO 3166 alpha-2 country codes to country names, as used in the UN/LOCODE codelist.
Field
Type
Description
CountryCode
string
ISO 3166 alpha-2 country code (2 uppercase letters).
CountryName
string
Official English name of the country.
function-classifiers
Lookup table defining the meaning of each position in the Function field of the code-list. Each code corresponds to a transport or logistics function.
Field
Type
Description
FunctionCode
string
Single-character function code (0–8 or B) used in the Function field of code-list.csv.
FunctionDescription
string
Human-readable description of the transport or logistics function.
status-indicators
Lookup table defining the meaning of the Status field in the code-list. Status codes indicate the approval or verification level of each location entry.
Field
Type
Description
STStatus
string
2-letter status code used in the Status field of code-list.csv.
STDescription
string
Human-readable description of the approval or verification status.
subdivision-codes
Lookup table of ISO 3166-2 subdivision codes (states, provinces, regions, etc.) referenced by the Subdivision field of the code-list.
Field
Type
Description
SUCountry
string
ISO 3166 alpha-2 country code for the subdivision.
SUCode
string
ISO 3166-2 subdivision code (without the country prefix).
SUName
string
Name of the subdivision (state, province, region, etc.).
SUType
string
Type of the administrative subdivision (e.g. Province, State, Region, Emirate). May be empty for some entries.
alias
Alternative names (aliases) for countries, extracted from UN/LOCODE source files. These are rows in the source data with Change code '=' and no location code.
Field
Type
Description
Country
string
ISO 3166 alpha-2 country code the alias applies to.
Name
string
Alternative country or region name, may include diacritics.
NameWoDiacritics
string
Alternative name with diacritics replaced by ASCII equivalents.
The United Nations Code for Trade and Transport Locations: five-character codes for ports, airports, rail and road terminals, cities and other places used in international trade and transport. The code list is maintained by UNECE.
Column definitions and types are in datapackage.json.
Data
data/code-list.csv: one row per location entry.
data/subdivision-codes.csv: ISO 3166-2 subdivision codes and names used by the Subdivision column.
data/country-codes.csv: country codes and names as used in the code list.
data/alias.csv: alternative names of countries.
data/function-classifiers.csv: the meaning of each position of the Function column.
data/status-indicators.csv: the meaning of the Status column.
Columns of data/code-list.csv:
Column
Meaning
Change
Change indicator: + newly added, | changed, # name changed, ! US location with a duplicate IATA code, X to be removed. Empty for entries that did not change
Country
ISO 3166 alpha-2 country code, for example AE. Defined in country-codes.csv
Location
3-character location code (letters and the digits 2 to 9), for example DXB. With Country it forms the 5-character UN/LOCODE
Name
Name of the location, with diacritics
NameWoDiacritics
The same name with diacritics replaced by ASCII letters
Subdivision
ISO 3166-2 subdivision code, for example DU. Defined in subdivision-codes.csv. May be empty
Status
Approval or verification status, for example AI. Defined in status-indicators.csv
Function
8-character string, one position for each function (port, rail terminal, airport and so on). A digit or letter means the function is present, a dash means it is not. Defined in function-classifiers.csv
Date
Date of the entry as YYMM, for example 2501 is January 2025. May be empty
IATA
IATA code, only when it differs from the UN/LOCODE location code. May be empty
Coordinates
Latitude and longitude as degrees and minutes with a letter for the direction, for example 2515N 05516E. May be empty
Remarks
Free-text remark. May be empty
Known limitations
The file follows UNECE's "Pre-Release (Latest)", not an official release. UNECE describes it as "for latest codes in between official releases", so it can contain codes approved after the last official biannual publication, and entries can still change.
Country + Location is not unique. Some places have two entries, for example an old and a changed name (one with # in Change). Use Change and Date to tell them apart.
Rows with Change set to X are entries UNECE marks for removal. They stay in the file until a later release drops them.
The code for Namibia is the two letters NA (in Country and in SUCountry). Many tools read the text NA as "missing". Read the files as text and keep empty cells empty: pd.read_csv("data/code-list.csv", dtype=str, keep_default_na=False).
Codes and Function strings are text. Location can be made only of digits and letters such as 5MS, and Function starts with digits or dashes. Do not let your tool turn them into numbers.
Coordinates is one text column in degrees and minutes, not two decimal numbers.
Rows without a location code (country-name rows and alias rows) are not in code-list.csv. The aliases are in alias.csv.
Data sources
UN/LOCODE, published by UNECE: the code list and its lookup tables. The build uses the file UNECE calls "Pre-Release (Latest)". Licence: unclear (see License).
Changes made to the source data: the script reads the release's Access database for the lookup tables and its three CSV parts for the code list. For code-list.csv it joins the three parts, moves the alias rows (Change set to =) to alias.csv, drops the country-name rows, swaps Status and Function where the release has them the wrong way round, removes duplicate rows (same country, location, name, subdivision, date and coordinates), and writes the columns in a fixed order. For subdivision-codes.csv it adds the subdivision type from the release's CSV file, collapses extra spaces and removes repeated lines. All files are written with LF line endings.
Not endorsed by, or affiliated with, UNECE or the United Nations.
Preparation
You need Python 3.12 or greater, make, and the tools mdbtools and gawk. Install them (macOS shown; on Ubuntu use sudo apt-get install mdbtools gawk):
Download the release into release/ and build the data:
./scripts/fetch_release.sh
make
scripts/fetch_release.sh downloads https://unlocode.unece.org/downloads/unlocode-latest.zip. To build from another zip, for example an official release, run UNLOCODE_URL=<zip url> ./scripts/fetch_release.sh. The zip must contain this folder layout:
Set PYTHON=<path> if python3 is not the interpreter that has the requirements installed (make PYTHON=.venv/bin/python).
A GitHub workflow (.github/workflows/update.yml) runs this on the first day of every month (at 03:00 UTC) and when started by hand. It commits data/ if something changed.
License
The licence of the UN/LOCODE data is unclear, because UNECE's own pages say different things. What we checked:
The terms of the UN/LOCODE site say the United Nations grants permission "to download and copy the information, documents and materials … for the User's personal, non-commercial use, without any right to resell or redistribute them or to compile or create derivative works therefrom", and that this is "subject to … more specific restrictions that may apply to specific Material".
The footer of the same site says: "All UN/CEFACT standards are free to use under CC By 4.0 license". UN/LOCODE is published through UN/CEFACT (Recommendation 16). The pages we read do not say whether that sentence covers the code list itself.
Recommendation 16 says updated versions of the directory "will be published on the UNECE website free of charge".
The source repository has a GPL-3.0 LICENSE file for the repository. Its data folder has no licence notice of its own.
We could not establish which of these applies to the data in this package. If you plan to redistribute it or use it commercially, ask UNECE for written confirmation first. We credit UNECE as the source in any case (see ATTRIBUTION.txt).
The maintainers place only their own work (the scripts, the column definitions and the file layout) under the Public Domain Dedication and License (PDDL). This does not cover the UN/LOCODE data itself.
API access
Access dataset files directly from scripts, code, or AI agents.
Each file has a stable URL (r-link) that you can use directly in scripts, apps, or AI agents. These URLs are permanent and safe to hardcode.