Reverse Geocoder

1.5.1 · maintenance · verified Wed Apr 15

Reverse Geocoder is a fast, offline Python library designed to convert geographic coordinates (latitude, longitude) into human-readable location data such as city, country, and administrative regions. It improves upon an existing library by utilizing a parallelized K-D tree for enhanced performance, especially for large inputs. The library uses GeoNames data, with a default population filter of >1000, and allows for custom data sources. The current version is 1.5.1, with its last release in September 2016, indicating a maintenance phase rather than active development.

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to import the library and perform reverse geocoding for a list of coordinate pairs. The `search` function returns a list of dictionaries, each containing details like city name, administrative regions, country code, and the nearest latitude/longitude from its internal database.

import reverse_geocoder as rg

# List of (latitude, longitude) tuples
coordinates = [
    (51.521458, -0.138850), # London
    (35.689487, 139.691706), # Tokyo
    (40.7127837, -74.0059413) # New York City
]

# Perform reverse geocoding
results = rg.search(coordinates)

# Print the results
for coord, result in zip(coordinates, results):
    print(f"Coordinates: {coord} -> Found: {result['name']}, {result['admin1']}, {result['cc']}")

# Expected output format (values may vary slightly based on data source)
# Coordinates: (51.521458, -0.13885) -> Found: London, England, GB
# Coordinates: (35.689487, 139.691706) -> Found: Tokyo, Tōkyō, JP
# Coordinates: (40.7127837, -74.0059413) -> Found: New York City, New York, US

view raw JSON →