A Python library for offline reverse geocoding. It improves on an existing library called reverse-geocoder developed by [Ajay Thampi]
- Besides city/town and country code, this library also returns the nearest latitude and longitude and also administrative regions 1 and 2.
- This library also uses a parallelised implementation of K-D trees which promises an improved performance especially for large inputs.
- Many extra information from OSM
The K-D tree is populated with cities that have a population > 1000. The source of the data is GeoNames.
- scipy
- numpy
- geopy
- pandas
- ast
The library supports two modes:
- Mode 1: Single-threaded K-D Tree (default, similar to [reverse_geocode] (https://pypi.python.org/pypi/reverse_geocode/1.0))
- Mode 2: Multi-threaded K-D Tree
import osm_rg as rg
city = (-33.86785, 151.20732)
results = rg.get(city) # default mode = 1, precision = 2
print results
The above code will output the following:
[{
'town': nan,
'village': nan,
'country': 'Australia',
'city': 'Sydney',
'country_code': 'au',
'geo_id': 2147714
}]
If you'd like to use the multi-threaded K-D tree, set mode = 2 as follows:
results = rg.get(city, mode=2)
- Major inspiration is from Ajay Thampi's [reverse_geocoder] (https://github.com/thampiman/reverse-geocoder) library
- Parallelised implementation of K-D Trees is extended from this article by Sturla Molden
- Geocoded data is from GeoNames