11

Just curious, is it possible to link ISO 3166-2 codes to Olson Time Zone Codes. For example the US has these Olson Time Zone Codes:

US  United States   America/Adak
US  United States   America/Anchorage
US  United States   America/Boise
US  United States   America/Chicago
US  United States   America/Denver
US  United States   America/Detroit
US  United States   America/Indiana/Indianapolis
US  United States   America/Indiana/Knox
US  United States   America/Indiana/Marengo
US  United States   America/Indiana/Petersburg
US  United States   America/Indiana/Tell_City
US  United States   America/Indiana/Vevay
US  United States   America/Indiana/Vincennes
US  United States   America/Indiana/Winamac
US  United States   America/Juneau
US  United States   America/Kentucky/Louisville
US  United States   America/Kentucky/Monticello
US  United States   America/Los_Angeles
US  United States   America/Menominee
US  United States   America/New_York
US  United States   America/Nome
US  United States   America/North_Dakota/Beulah
US  United States   America/North_Dakota/Center
US  United States   America/North_Dakota/New_Salem
US  United States   America/Phoenix
US  United States   America/Yakutat
US  United States   Pacific/Honolulu

If so, is there a free and curated data source? Alternatively, are there polygon data of time zones available?

2

3 Answers 3

4
+25

You can create an ISO 3166-2 and time zone list using the Geonames API. If you use the general search API, you can pass a wildcard in for the name and specify the feature code and feature class parameters you want, to return all entities of that type. The time zone name and differences for GMT and DST are among the attributes returned.

For example, the following returns all the first-level administrative divisions of the United States (i.e. states and territories). For country we specify the two-letter ISO country code, feature class A (countries, states, and region features), and feature code ADM1 to get the first-level admin divisions. This link is for illustration purposes and won't render anything. You need to register and get your own username and tack it on to the end. I've included a screenshot to illustrate a portion of the result you'd see in a web browser.

http://api.geonames.org/searchJSON??name=*&country=US&featureClass=A&featureCode=ADM1&style=full&username=

The result includes the time zone attribute as a dictionary-like object (to capture the three time zone attributes and account for the fact that areas may span more than one zone), and the values for adminCode1 and adminName1 attributes are the ISO-3166-2 code and division name.

enter image description here

Some variants: if you remove JSON from the search string you'll get XML instead. If you don't want to loop through a list of countries, you can insert the asterisk wildcard for country to grab them all, but this will be a fairly large request. For testing purposes you can add &maxRows=N to limit the number of rows returned. You will need to register to get an API key (the value for the username), but it's free. Use your favorite scripting language to make the request and extract the specific attributes you want to create a table. While there is a specific timezone API, it requires you to pass in long and lat coordinates.

If APIs are not your thing, you can download country-level delimited text files that contain ALL features within each country, and even one file that contains the entire world. You can load these into a database and query just the features and attributes you want, although this will be more tedious and time consuming given the number of country files or the sheer size of the world file.

3

As to shapefiles, have a look at:

But probably you need just this:

$ awk '!/#/ {print $1,$3}' /usr/share/zoneinfo/zone.tab

See also:

Update

As for ISO 3166-2 codes, try this query on Wikidata:

SELECT ?regionLabel ?code ?zoneLabel {
  ?region wdt:P300 ?code .
  ?region wdt:P421 ?zone .
  SERVICE wikibase:label { bd:serviceParam wikibase:language "en". }
} ORDER BY ?code

This list is not very comprehensive and accurate, but contains daylight saving time information.

There is also 5-years old dataset from Mabrian.

1
  • 3
    This is a great mapping of country to timezones, but the original question requested a mapping of country/region to timezone (ISO 3166-2 are region codes). Would be great if that more specific information existed.
    – minou
    Commented Jul 8, 2018 at 13:48
0

You might want to refer to the Unicode CLDR (Common Locale Data Repository) time zones data, which provides IANA time zone and ISO3166 country code mapping.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.