Reverse Geocode

1.6.6 · active · verified Thu Apr 16

Reverse Geocode is a Python library (current version 1.6.6) for offline reverse geocoding. It translates latitude/longitude coordinates into the nearest known country, state, and city using a k-d tree structure built from GeoNames data. This is particularly useful for batch processing a large number of coordinates without relying on external web APIs. The project maintains an infrequent release cadence.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart demonstrates how to perform reverse geocoding for both single and multiple latitude/longitude coordinates using the `get()` and `search()` functions, respectively. The results include country code, city, latitude, longitude, population, state, and country.

import reverse_geocode

# Example for a single coordinate
melbourne_coord = (-37.81, 144.96)
result_single = reverse_geocode.get(melbourne_coord)
print(f"Single result: {result_single}")

# Example for multiple coordinates
coordinates = (
    (40.71427000, -74.00597000), # New York City
    (-37.81, 144.96) # Melbourne
)
results_batch = reverse_geocode.search(coordinates)
print(f"Batch results: {results_batch}")

view raw JSON →