#47: finding a time zone give lat/lon coordinates
Solved!
A little while ago we started using time zones in iNat, which was more troublesome than anticipated. One problem I ran into was automatically setting the time zone from pre-existing observations given their lat/lon. I ended up http://www.earthtools.org/webservices.htm, which is a fine little service, but I didn't end up incorporating it into the app because I didn't feel like implementing the caching restrictions they ask for (yes, I am insanely lazy). So...
use the flickr API
- kueda on May 22, 2009, 09:06 PM UTC
The Flickr API is amazing. using the places.findByLatLon method, you can not only reverse geocode your coordinates, but each place response comes with a a TZ time zone identifier! TZ is the database used by the Rails time zone stuff, so it's perfect for use in rails. Here's a trivial example using the excellent flickraw gem:
Also, it's Flickr, so pretty robust and open.
o = Observation.first
places = flickr.places.findByLatLon(:lat => o.latitude, :lon => o.longitude)
o.time_zone = ActiveSupport::TimeZone::MAPPING.invert[places.first.timezone]
Also, it's Flickr, so pretty robust and open.