Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #73572 > unrolled thread
| Started by | codetarsier@gmail.com |
|---|---|
| First post | 2014-06-25 05:53 -0700 |
| Last post | 2014-06-26 00:44 +0400 |
| Articles | 10 — 9 participants |
Back to article view | Back to comp.lang.python
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
| From | codetarsier@gmail.com |
|---|---|
| Date | 2014-06-25 05:53 -0700 |
| Subject | How to get Timezone from latitude/longitude ? |
| Message-ID | <9d6022cc-c5ca-448b-921f-fba9241f4b5c@googlegroups.com> |
Hi, 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. Thanks in advance.
[toc] | [next] | [standalone]
| From | Bernd Nawothnig <Bernd.Nawothnig@t-online.de> |
|---|---|
| Date | 2014-06-25 15:09 +0200 |
| Message-ID | <69uq7b-qrg.ln1@bernd.nawothnig.dialin.t-online.de> |
| In reply to | #73572 |
On 2014-06-25, 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. You can find the data as a zipped shapefile here: http://efele.net/maps/tz/world/ Download the data and use pyshp and/or gdal/ogr for the lookup. It may not be as simple as you wanted it to be, but it is possible. Bernd -- no time toulouse
[toc] | [prev] | [next] | [standalone]
| From | Larry Martell <larry.martell@gmail.com> |
|---|---|
| Date | 2014-06-25 09:09 -0400 |
| Message-ID | <mailman.11234.1403701769.18130.python-list@python.org> |
| In reply to | #73572 |
On Wed, Jun 25, 2014 at 8:53 AM, <codetarsier@gmail.com> wrote: > Hi, > > 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. > > Thanks in advance. It took me 30 seconds on google to find this: https://github.com/pegler/pytzwhere
[toc] | [prev] | [next] | [standalone]
| From | Chris Angelico <rosuav@gmail.com> |
|---|---|
| Date | 2014-06-25 23:27 +1000 |
| Message-ID | <mailman.11235.1403702847.18130.python-list@python.org> |
| In reply to | #73572 |
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
[toc] | [prev] | [next] | [standalone]
| From | Marko Rauhamaa <marko@pacujo.net> |
|---|---|
| Date | 2014-06-25 17:00 +0300 |
| Message-ID | <87tx79jdi4.fsf@elektro.pacujo.net> |
| In reply to | #73575 |
Chris Angelico <rosuav@gmail.com>: > Are you trying to use a user's IP geolocation data to pick a timezone? > Because that's doomed to failure. Some years back my employer switched ISPs in Southern California. The following morning Google displayed everything in Hebrew. It took a week or two to be corrected. Marko
[toc] | [prev] | [next] | [standalone]
| From | Grant Edwards <invalid@invalid.invalid> |
|---|---|
| Date | 2014-06-25 14:24 +0000 |
| Message-ID | <loem2p$5ad$1@reader1.panix.com> |
| In reply to | #73576 |
On 2014-06-25, Marko Rauhamaa <marko@pacujo.net> wrote:
> Chris Angelico <rosuav@gmail.com>:
>
>> Are you trying to use a user's IP geolocation data to pick a timezone?
>> Because that's doomed to failure.
>
> Some years back my employer switched ISPs in Southern California. The
> following morning Google displayed everything in Hebrew. It took a week
> or two to be corrected.
Learning Hebrew in a week or two is a pretty impressive feat.
--
Grant Edwards grant.b.edwards Yow! ... I want to perform
at cranial activities with
gmail.com Tuesday Weld!!
[toc] | [prev] | [next] | [standalone]
| From | Ethan Furman <ethan@stoneleaf.us> |
|---|---|
| Date | 2014-06-25 07:34 -0700 |
| Message-ID | <mailman.11236.1403708211.18130.python-list@python.org> |
| In reply to | #73577 |
On 06/25/2014 07:24 AM, Grant Edwards wrote: > On 2014-06-25, Marko Rauhamaa wrote: >> >> Some years back my employer switched ISPs in Southern California. The >> following morning Google displayed everything in Hebrew. It took a week >> or two to be corrected. > > Learning Hebrew in a week or two is a pretty impressive feat. Maybe he learned using one of those language classes I keep hearing about in my email... -- ~Ethan~
[toc] | [prev] | [next] | [standalone]
| From | Gregory Ewing <greg.ewing@canterbury.ac.nz> |
|---|---|
| Date | 2014-06-26 11:29 +1200 |
| Message-ID | <c114akFl4eU1@mid.individual.net> |
| In reply to | #73579 |
Ethan Furman wrote: > On 06/25/2014 07:24 AM, Grant Edwards wrote: > >> On 2014-06-25, Marko Rauhamaa wrote: >> >>> Some years back my employer switched ISPs in Southern California. The >>> following morning Google displayed everything in Hebrew. It took a week >>> or two to be corrected. >> >> Learning Hebrew in a week or two is a pretty impressive feat. > > Maybe he learned using one of those language classes I keep hearing > about in my email... Nah, the solution's obvious -- just use Google Translate to turn it back into English. -- Greg
[toc] | [prev] | [next] | [standalone]
| From | codetarsier@gmail.com |
|---|---|
| Date | 2014-06-26 02:24 -0700 |
| Message-ID | <5afdaf7f-17ec-4005-85c8-a3e304ed5909@googlegroups.com> |
| In reply to | #73596 |
Thanks for the help people. I was looking for the Malyasia City(lat/long)timezones.
[toc] | [prev] | [next] | [standalone]
| From | Akira Li <4kir4.1i@gmail.com> |
|---|---|
| Date | 2014-06-26 00:44 +0400 |
| Message-ID | <mailman.11243.1403729110.18130.python-list@python.org> |
| In reply to | #73572 |
Larry Martell <larry.martell@gmail.com> writes: > On Wed, Jun 25, 2014 at 8:53 AM, <codetarsier@gmail.com> wrote: >> Hi, >> >> 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. >> >> Thanks in advance. > > It took me 30 seconds on google to find this: > > https://github.com/pegler/pytzwhere Note: tzwhere may consume 750GB memory doing nothing https://github.com/pegler/pytzwhere/pull/10 You could generate a postgis timezone database from efele.net/tz map or use an online service instead http://stackoverflow.com/a/16519004 -- akira
[toc] | [prev] | [standalone]
Back to top | Article view | comp.lang.python
csiph-web