Offline Reverse Geocoding in Python

前端 未结 2 1268
挽巷
挽巷 2020-12-30 17:48

I am writing a Python script that passes a latitude and longitude to a module and performs a reverse geocode function to return the address of the location. I have been usi

2条回答
  •  猫巷女王i
    2020-12-30 18:07

    I created a module to do exactly that: https://bitbucket.org/richardpenman/reverse_geocode

    >>> import reverse_geocode 
    >>> coordinates = (-37.81, 144.96), (31.76, 35.21)
    >>> reverse_geocode.search(coordinates)
    [{'city': 'Melbourne', 'code': 'AU', 'country': 'Australia'},
     {'city': 'Jerusalem', 'code': 'IL', 'country': 'Israel'}]
    

    Internally it uses locations from the geonames database and a k-d tree to find the nearest neighbour.

提交回复
热议问题