Geohash
import pygeohash as pgh
pgh.encode(42.6, -5.6)
# >>> 'ezs42e44yx96'
pgh.encode(42.6, -5.6, precision=5)
# >>> 'ezs42'
pgh.decode('ezs42')
# >>> (42.6, -5.6)
pgh.geohash_approximate_distance('shi3u', 'sh83n')
# >>> 625441
UTM
import utm
from timezonefinder import TimezoneFinder
tf = TimezoneFinder()
latitude = 45.758718
longitude = -108.502049
s = utm.from_latlon(float(latitude), float(longitude))
utmzone = str(s[2])+str(s[3])
utmeasting = s[0]
utmnorthing = s[1]
zonenumber = s[2]
zoneletter = s[3]
timezone = tf.closest_timezone_at(lng=float(longitude), lat=float(latitude))
print(utmeasting, utmnorthing, zonenumber, zoneletter, timezone)
# 694259.585390889 5070274.641107877 12 T America/Denver
import pygeohash as pgh
s = pgh.encode(45.758718, -108.502049)
print(s) #c84u6fp5z523
和https://www.alltopsights.com/attraction-the-rimrocks-montana-mt/的结果一致
反查地址
from geopy.geocoders import Nominatim
from geopy.exc import GeocoderTimedOut
my_address = '1600 Pennsylvania Avenue NW Washington, DC 20500'
geolocator = Nominatim(timeout=10)
location = geolocator.reverse("44.333469,-68.405938")
print(location)
网友评论