2

Is there a method or does anyone know of the mathematical principles behind calculating the timezone from a given longitude? Similar to

http://www.mathworks.co.uk/help/map/ref/timezone.html

I can use this function fine, but it requires the mapping toolbox and as I'm trying to write a function that can be used with any version of matlab this will not suffice. Can anyone provide any suggestions?

I am also writing the functions in R, so if anyone knows of any procedure that can be applied to both matlab and R, that would be great.

Would be OK to define some meridian zones as

MeridianZones = 0:15:165;

and then define the corresponding time zone changes:

TimeZones1 = 0:1:14;
TimeZones2 = -1:-1:-11;
TimeZones = [fliplr(TimeZones2),TimeZones1];

And then use MeridianZones and TimeZones to give a rough approximation of the change in time for a given longitude.

KatyB
  • 3,920
  • 7
  • 42
  • 72
  • 6
    Although in principle 360 degrees / 24 hours = 15 degrees per time zone, in practice time zones have funny shapes due to government administration of time zones. – Paul Aug 16 '13 at 10:09
  • I might be more difficult thant you think, because it does not depend only on longitude: http://www.timeanddate.com/time/map/ – Luis Mendo Aug 16 '13 at 10:10
  • Also, don't forget that `daylight savings time` is inconsistently implemented as well. – Paul Aug 16 '13 at 10:12
  • 1
    I think the best way would be to find a shapefile that delineates the time-zones and use `over` from `sp` to perform a *point-in-polygon* sampling to get the right time zone. – Simon O'Hanlon Aug 16 '13 at 10:20
  • 2
    @Paul Furthermore it looks like such a shapefiles [***exists!***](http://efele.net/maps/tz/world/). that was my first hit on Google. Can anyone see a drawback of this approach? – Simon O'Hanlon Aug 16 '13 at 10:22
  • Ubuntu has a way to do something like this during system configuration. You click on a map and it sets TZ. Not surprising some free code should exist to help out. I expected more of a db of city names and TZ. – Paul Aug 16 '13 at 10:25
  • Is it possible to do something along the lines of finding the closest time zone, taking a time zone to the closest meridian i.e. ignoring government administration of time zones? Could one first create a set of meridians like MeridianZones = 0:15:165; and then use this to find the time zones? – KatyB Aug 16 '13 at 10:31
  • @SimonO101 That sounds like a reasonable thing to try. It will only be as good as the data. – Paul Aug 16 '13 at 10:43
  • 3
    there are online services that can translate latitude/longitude into a timezone. You could also get the info _offline_ using shapefiles mentioned by @SimonO101 [(by querying a timezone db generated from the shapefiles or using a library for your language that does it for you)](http://stackoverflow.com/a/16519004/4279). – jfs Aug 16 '13 at 10:56
  • 1
    OK, let's back up. Kate: what is the problem you are trying to solve? As should be clear from previous comments, time zones are as much geopolitical as navigational, so the algorithm you select is going to depend completely on the problem itself. – Carl Witthoft Aug 16 '13 at 11:30
  • 1
    My main aim here is to estimate insolation a ta given location and when calculating the solar hour angle, the equation requires a value for time zone. – KatyB Aug 16 '13 at 12:22
  • 2
    In that case (solar insolation), I strongly recommend doing all your work in Zulu (GMT) time base, and adjusting for "local time" later on. Consider that you'll need to adjust for Daylight Savings, not to mention some wacky sub-country areas which are 1/2 hour off! – Carl Witthoft Aug 16 '13 at 13:19

0 Answers0