Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #73575

Re: How to get Timezone from latitude/longitude ?

Path csiph.com!usenet.pasdenom.info!aioe.org!news.stack.nl!newsfeed.xs4all.nl!newsfeed3a.news.xs4all.nl!xs4all!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail
Return-Path <rosuav@gmail.com>
X-Original-To python-list@python.org
Delivered-To python-list@mail.python.org
X-Spam-Status OK 0.108
X-Spam-Level *
X-Spam-Evidence '*H*': 0.78; '*S*': 0.00; 'defines': 0.09; 'subject:How': 0.10; 'cc:addr:python-list': 0.11; '(positive': 0.16; 'dst,': 0.16; 'evening,': 0.16; 'failure.': 0.16; 'from:addr:rosuav': 0.16; 'from:name:chris angelico': 0.16; 'greenwich,': 0.16; 'guessing': 0.16; 'islands': 0.16; 'morning,': 0.16; 'normally,': 0.16; 'rough': 0.16; 'those,': 0.16; 'timezones': 0.16; 'subject: ?': 0.16; 'appropriate': 0.16; 'wrote:': 0.18; 'wed,': 0.18; 'trying': 0.19; '(where': 0.19; 'otherwise,': 0.22; 'cc:addr:python.org': 0.22; 'cc:2**0': 0.24; 'define': 0.26; 'first,': 0.26; 'subject:/': 0.26; 'skip:" 20': 0.27; 'header:In-Reply-To:1': 0.27; 'idea': 0.28; 'points': 0.29; 'message-id:@mail.gmail.com': 0.30; "i'm": 0.30; '(which': 0.31; 'getting': 0.31; '25,': 0.31; 'though.': 0.31; "user's": 0.31; 'figure': 0.32; 'guess': 0.33; 'actual': 0.34; 'subject:from': 0.34; 'something': 0.35; 'but': 0.35; 'received:google.com': 0.35; 'there': 0.35; 'really': 0.36; 'east': 0.36; 'ahead': 0.38; 'city.': 0.38; 'pm,': 0.38; 'rather': 0.38; 'bad': 0.39; 'enough': 0.39; 'users': 0.40; 'even': 0.60; 'skip:u 10': 0.60; 'easy': 0.60; 'office': 0.60; 'negative': 0.60; 'then,': 0.60; 'most': 0.60; 'new': 0.61; 'entire': 0.61; "you're": 0.61; 'pick': 0.64; 'different': 0.65; 'civil': 0.65; 'city': 0.66; 'fact,': 0.69; 'theoretical': 0.74; 'day': 0.76; 'country': 0.77; 'subject:get': 0.81; 'geolocation': 0.84; 'gps': 0.84; 'longitude': 0.84; 'olsen': 0.84; 'presumably': 0.84; 'surface': 0.84; 'west),': 0.84; 'to:none': 0.92; 'hand,': 0.93
DKIM-Signature v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:in-reply-to:references:date:message-id:subject:from:cc :content-type:content-transfer-encoding; bh=CIxdJo1FdPBj/7zdOUN8I7t0JtJQ2osEACvZ9m2qX9Y=; b=uc9E9iMB/NXKxunWK9R0P8prtwLNHT4ByUJTs+h8Av13MKWR4PKgzYTnLTSQcrUCom mDuc5TKVdKTyO0SKg4H4+bwW2s5RsNSulXID32J92hbwQkOYOAWSb7Oc3p1FFNIE46/v k6EgtG/0vpGyGhmwv8+QvA5kz+bDhaSskQ4SVuUWfiSTw1rSGUoomOhRR9bAuKHQQ5+f qwKP7vCYOYqqHd14e2JPxzbn7JEiZfhx7RnX5y/fmjIP3ZDWQ2gF6dbtSeaQrFtwsWQN yP7UCSIprpwBywOZS7ecOoUnzMP+a5JnLk4pPJ7tsYyj0khTULV6WOA4nOqJIGjaKpZg GnoA==
MIME-Version 1.0
X-Received by 10.53.12.229 with SMTP id et5mr5815031vdd.32.1403702844592; Wed, 25 Jun 2014 06:27:24 -0700 (PDT)
In-Reply-To <9d6022cc-c5ca-448b-921f-fba9241f4b5c@googlegroups.com>
References <9d6022cc-c5ca-448b-921f-fba9241f4b5c@googlegroups.com>
Date Wed, 25 Jun 2014 23:27:24 +1000
Subject Re: How to get Timezone from latitude/longitude ?
From Chris Angelico <rosuav@gmail.com>
Cc "python-list@python.org" <python-list@python.org>
Content-Type text/plain; charset=UTF-8
Content-Transfer-Encoding quoted-printable
X-BeenThere python-list@python.org
X-Mailman-Version 2.1.15
Precedence list
List-Id General discussion list for the Python programming language <python-list.python.org>
List-Unsubscribe <https://mail.python.org/mailman/options/python-list>, <mailto:python-list-request@python.org?subject=unsubscribe>
List-Archive <http://mail.python.org/pipermail/python-list/>
List-Post <mailto:python-list@python.org>
List-Help <mailto:python-list-request@python.org?subject=help>
List-Subscribe <https://mail.python.org/mailman/listinfo/python-list>, <mailto:python-list-request@python.org?subject=subscribe>
Newsgroups comp.lang.python
Message-ID <mailman.11235.1403702847.18130.python-list@python.org> (permalink)
Lines 43
NNTP-Posting-Host 2001:888:2000:d::a6
X-Trace 1403702847 news.xs4all.nl 2950 [2001:888:2000:d::a6]:39635
X-Complaints-To abuse@xs4all.nl
Xref csiph.com comp.lang.python:73575

Show key headers only | View raw


On Wed, Jun 25, 2014 at 10:53 PM,  <codetarsier@gmail.com> wrote:
> I'm looking for a python-library which can help me to get Timezone and Timezone-offset(UTC) from latitude/longitude.
>
> I'm not able to find an easy way to do it.

There isn't an easy way to do it.

At best, you would have to do a two-step lookup: first, figure out
what country and city you're in, based on lat/long; and then, look up
the appropriate timezone from the city. Unfortunately that won't
actually be perfect, because there are points on this planet's surface
that cannot be unambiguously assigned timezones... because timezones
are really messy.

Normally, the way to define timezones would be with the Olsen database
(tzdata), which defines "Australia/Melbourne" (where I live),
"America/Merida" (which is not a reimagining of "Brave" on a different
continent), "Africa/Libreville" (which presumably is where a popular
office suite came from), and so on. If you can get your users to pick
based on those, your work will be easy and unambiguous. Otherwise,
you're going to have a lot of work trying to recreate that...

Why do you need to work this out? Are you trying to use a user's IP
geolocation data to pick a timezone? Because that's doomed to failure.
Even if you have something like a phone's GPS fix, trying to guess the
timezone based on that is a bad idea. In fact, guessing is almost
always a bad idea.

On the other hand, if all you need is a rough approximation, just take
the longitude (positive if you're east of Greenwich, negative if
west), and multiply it by 24 hours/360° to get a theoretical timezone.
That's good enough for planting on a map, or for getting a rough idea
of whether it's morning, noon, evening, or night; most actual civil
timezones will be broadly near to that figure. (Some are a long way
away from it, though. New Zealand's Chatham Islands are at around
176.5°W, for a theoretical timezone of roughly UTC-11:45, but the
actual timezone is UTC+12:45, almost but not exactly an entire day
ahead of where you might think.) Of course, that ignores every civil
invention, including the abomination of DST, but that might be
considered an advantage rather than a flaw...

ChrisA

Back to comp.lang.python | Previous | NextPrevious in thread | Next in thread | Find similar | Unroll thread


Thread

How to get Timezone from latitude/longitude ? codetarsier@gmail.com - 2014-06-25 05:53 -0700
  Re: How to get Timezone from latitude/longitude ? Bernd Nawothnig <Bernd.Nawothnig@t-online.de> - 2014-06-25 15:09 +0200
  Re: How to get Timezone from latitude/longitude ? Larry Martell <larry.martell@gmail.com> - 2014-06-25 09:09 -0400
  Re: How to get Timezone from latitude/longitude ? Chris Angelico <rosuav@gmail.com> - 2014-06-25 23:27 +1000
    Re: How to get Timezone from latitude/longitude ? Marko Rauhamaa <marko@pacujo.net> - 2014-06-25 17:00 +0300
      Re: How to get Timezone from latitude/longitude ? Grant Edwards <invalid@invalid.invalid> - 2014-06-25 14:24 +0000
        Re: How to get Timezone from latitude/longitude ? Ethan Furman <ethan@stoneleaf.us> - 2014-06-25 07:34 -0700
          Re: How to get Timezone from latitude/longitude ? Gregory Ewing <greg.ewing@canterbury.ac.nz> - 2014-06-26 11:29 +1200
            Re: How to get Timezone from latitude/longitude ? codetarsier@gmail.com - 2014-06-26 02:24 -0700
  Re: How to get Timezone from latitude/longitude ? Akira Li <4kir4.1i@gmail.com> - 2014-06-26 00:44 +0400

csiph-web