A Python library for offline reverse geocoding. It improves on an existing library called reverse_geocode developed by Richard Penman. The library was built with speed in mind and it can geocode 10 million GPS coordinates in under 30 seconds on a machine with 8 cores.
Based on the "Geolocation" category.
Alternatively, view Reverse Geocoder alternatives based on common mentions on social networks and blogs.
* Code Quality Rankings and insights are calculated and provided by Lumnify.
They vary from L1 to L5 with "L5" being the highest.
Do you think we are missing an alternative of Reverse Geocoder or a related project?
A Python library for offline reverse geocoding. It improves on an existing library called reverse_geocode developed by Richard Penman.
UPDATE (15-Sep-16): v1.5.1 released! See release notes below.
Ajay Thampi | @thampiman | opensignal.com | ajaythampi.com
By default, the K-D tree is populated with cities that have a population > 1000. The source of the data is GeoNames. You can also load a custom data source so long as it is a comma-separated file with header (like rg_cities1000.csv), containing the following columns:
lat: Latitudelon: Longitudename: Name of placeadmin1: Admin 1 regionadmin2: Admin 2 regioncc: ISO 3166-1 alpha-2 country codeFor usage instructions, see below.
For first time installation,
$ pip install reverse_geocoder
Or upgrade an existing installation using,
$ pip install --upgrade reverse_geocoder
Package can be found on PyPI.
The library supports two modes:
import reverse_geocoder as rg
coordinates = (51.5214588,-0.1729636),(9.936033, 76.259952),(37.38605,-122.08385)
results = rg.search(coordinates) # default mode = 2
print results
The above code will output the following:
[{'name': 'Bayswater',
'cc': 'GB',
'lat': '51.51116',
'lon': '-0.18426',
'admin1': 'England',
'admin2': 'Greater London'},
{'name': 'Cochin',
'cc': 'IN',
'lat': '9.93988',
'lon': '76.26022',
'admin1': 'Kerala',
'admin2': 'Ernakulam'},
{'name': 'Mountain View',
'cc': 'US',
'lat': '37.38605',
'lon': '-122.08385',
'admin1': 'California',
'admin2': 'Santa Clara County'}]
If you'd like to use the single-threaded K-D tree, set mode = 1 as follows:
results = rg.search(coordinates,mode=1)
To use a custom data source for geocoding, you can load the file in-memory and pass it to the library as follows:
import io
import reverse_geocoder as rg
geo = rg.RGeocoder(mode=2, verbose=True, stream=io.StringIO(open('custom_source.csv', encoding='utf-8').read()))
coordinates = (51.5214588,-0.1729636),(9.936033, 76.259952),(37.38605,-122.08385)
results = geo.query(coordinates)
As mentioned above, the custom data source must be comma-separated with a header as rg_cities1000.csv.
The performance of modes 1 and 2 are plotted below for various input sizes.
[Performance Comparison](performance.png)
Mode 2 runs ~2x faster for very large inputs (10M coordinates).
Copyright (c) 2015 Ajay Thampi and contributors. This code is licensed under the LGPL License.
*Note that all licence references and agreements mentioned in the Reverse Geocoder README section above
are relevant to that project's source code only.
Do not miss the trending, packages, news and articles with our weekly report.