Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there a reputable source that provides mappings of UN/LOCODEs to Olsen Timezones?

I've been researching CLDR and IANA in order to find a centralized mapping of UN/LOCODEs to Olsen Timezones.

Ideally I would like to have for example:

+--------------+--------------------+
|un_locode     |timezone            |
+--------------+--------------------+
|USLAX         | America/Los_Angeles|
+--------------+--------------------+

for every UN/LOCODE.

Are my nube skills failing me in understanding how to use these sources to reach my goal? (If so please help point me towards the scripting that would allow me to automate providing these mappings).

Or, do these sources fail to have the data correlation that I'm looking for? (If so please let me know if you have a reliable source).

like image 232
mattbrosenberg Avatar asked Nov 10 '15 20:11

mattbrosenberg


1 Answers

We faced the exact same problem and hence had to provide a solution.

This solution involves linking the UN/LOCODES database with a geolocation/timezone database. There are a few caveats to this approach that were captured by Matt Johnson's answer and the accompanying comments.

Namely:

  • the UN/LOCODE database of coordinates is not complete[1] and sometime has inaccurate data[2]
  • in some cases, a 1 to 1 mapping between the UN/LOCODE and a timezone is impossible due to the political nature of the timezones.
  • the two points above are worsened by the inaccuracy of free coordinates-to-timezone databases. It is helpful to get a dataset that also includes territorial waters so that ports timezones can be properly linked to the country they belong.

The following repository https://github.com/Portchain/un_locodes_sql contains the code to extract and link the data. It outputs a SQL file that can be imported into a PostgreSQL DB. The geolocation/timezone data is based on the geo-tz[3] module which seems to source its data from timezone-boundary-builder[4].

Again, the list provided by our repository is of course incomplete and inaccurate. If you see any error in the data, please open a github issue and let's make an accurate, open source list of UN/LOCODE, coordinates and timezone information.

  • [1] For example, both Los Angeles and San Francisco, USA (USLAX & USSFO) are missing coordinates in the UN/LOCODE database.
  • [2] The petroleum port of Abu al Bukhoosh (AEABU) is situated in Abu Dhabi (UAE). Its coordinates in the UN/LOCODE database position the port right in the middle of the Persian Gulf (https://www.port-directory.com/ports/abu_al_bukhoosh/). When resolved, this causes the timezone to be unknown.
  • [3] https://github.com/evansiroky/node-geo-tz
  • [4] https://github.com/evansiroky/timezone-boundary-builder
like image 106
Nicolas Avatar answered Sep 24 '22 15:09

Nicolas