MeridianMERIDIAN

Country Code

geography.location.country_code

ISO 3166-1 alpha-2 country code (2 letters, e.g., US, FR, JP). Universal format.

Shape

Pattern
^[A-Z]{2}$
ValueLengthShape
US2matches
FR2matches
JP2matches
DE2matches
CA2matches
U1rejected: one character short

Told apart

1 of the 5 other location types accept every one of these samples on shape alone.

Going the other way, this type's own rule accepts 5 of 5 samples of State/Province Code.

Background

Origin

ISO 3166-1 alpha-2 codes are two-letter country codes defined in ISO 3166-1, part of the ISO 3166 standard published by the International Organization for Standardization (ISO).[1] ISO 3166-1 alpha-2 codes represent countries, dependent territories, and special areas of geographical interest.[1] ISO 3166-1 defines three sets of country codes: alpha-2, alpha-3 and numeric.[2] The country codes have been published as ISO 3166-1 since 1997, when ISO 3166 was expanded into three parts.[2]

According to the ISO 3166 Maintenance Agency (ISO 3166/MA), a new country name can enter ISO 3166-1 only by being registered in the United Nations Terminology Bulletin Country Names or in the UN Statistics Division's Country and Region Codes for Statistical Use.[2] According to the ISO 3166/MA, the codes are chosen "to reflect the significant, unique component of the country name in order to allow a visual association between country name and country code".[2] The United Kingdom is officially assigned the alpha-2 code GB rather than UK, based on its official name "United Kingdom of Great Britain and Northern Ireland".[2] Germany is assigned the alpha-2 code DE, based on its native name "Deutschland".[2]

ISO 3166-1 has 249 current officially assigned alpha-2 codes.[1] The alpha-2 codes AA, QM to QZ, XA to XZ, and ZZ can be user-assigned.[1][2] The ISO 3166/MA will never use user-assigned codes when updating the standard.[1][2] ISO 3166-1 divides its reserved alpha-2 codes into exceptional reservations, transitional reservations and indeterminate reservations.[1] A country is normally assigned new ISO 3166-1 codes if it changes its name or its territorial boundaries.[2] As of July 2013, ISO publishes changes to ISO 3166-1 in its online catalogue only, and no longer publishes newsletters.[2]

Use

Starting in 1985, ISO 3166-1 alpha-2 codes have been used in the Domain Name System as country code top-level domains (ccTLDs).[1] The United Kingdom, whose alpha-2 code is GB, uses .uk instead of .gb as its ccTLD.[1] Treat a domain suffix as a close cousin of the alpha-2 code rather than the same thing, and map the exceptions before joining one to the other. (Meridian's view)

Eurostat's glossary of country codes lists EL as the code for Greece.[3] Eurostat's glossary of country codes lists UK as the code for the United Kingdom.[3] Eurostat's glossary of country codes lists XK as the code for Kosovo.[3] Eurostat's glossary notes that XK is a code used for practical reasons and not an official ISO country code.[3] The code XK is used by the European Commission, the IMF, SWIFT, the CLDR and other organisations as a temporary country code for Kosovo.[1] The Unicode Common Locale Data Repository (CLDR) assigns the user-assigned code ZZ to represent "Unknown or Invalid Territory".[1]

FIPS 10-4 was a list of two-letter country codes used by the U.S. Government for geographical data processing in many publications, such as the CIA World Factbook.[4] FIPS 10-4 codes are similar to, but sometimes incompatible with, the ISO 3166-1 alpha-2 country codes.[4] On September 2, 2008, NIST withdrew FIPS 10-4 as a Federal Information Processing Standard.[4][5] In FIPS 10-4, GM is the code for Germany.[5] In FIPS 10-4, AS is the code for Australia.[5] The UN Statistics Division's M49 table gives GM as the ISO-alpha2 code for Gambia.[6] The UN Statistics Division's M49 table gives AS as the ISO-alpha2 code for American Samoa.[6] The UN Statistics Division's M49 table gives AU as the ISO-alpha2 code for Australia.[6] Two-letter codes that came from older US government sources deserve a spot check against a few countries you know before you trust them as ISO codes. (Meridian's view)

The UN Statistics Division's M49 table gives NA as the ISO-alpha2 code for Namibia.[6] The pandas IO documentation lists 'NA' among the default values that are recognised as missing (NaN) when reading text files.[7] The pandas IO documentation says that specifying keep_default_na=False completely overrides the default values that are recognised as missing.[7] Read a country column as text with default missing-value detection switched off, then check that Namibia is still there. (Meridian's view)

Where you'll meet it

The UN Statistics Division's table of standard country or area codes for statistical use (M49) publishes an ISO-alpha2 code beside each country or area's M49 code.[6] GLEIF's Accepted Legal Jurisdictions Code List is based on ISO 3166 and specifies more than 300 different codes.[8]

Detection notes

v1 migration: Was address.country_code. Transform uppercases. ISO 3166-1 alpha-2 standard. Enum contains 249 officially-assigned codes. User-assigned ranges (AA, QM-QZ, XA-XZ, ZZ) excluded.

In Meridian's open data

Use it

CLI · DuckDB
$ finetype infer -i "US" --mode column
→ geography.location.country_code

SELECT ft_infer('US');
-- → 'geography.location.country_code'
Cast expression
UPPER(CAST({col} AS VARCHAR))

Schema

https://meridian.online/schemas/geography.location.country_code · Frictionless type string

finetype taxonomy geography.location.country_code -o json-schema

Aliases

iso_3166_1_alpha_2

Type Registry