A comprehensive geocoding library with multiple fallback providers and postal code lookup.
Project description
Robust Geocoder
A comprehensive geocoding library with multiple fallback providers. Supports single location queries and parallel batch processing.
Features
- Multiple geocoding providers with fallback logic:
- Geopy Nominatim (OpenStreetMap)
- Wikidata SPARQL
- Photon API
- DuckDuckGo Instant Answer (free)
- Serper API (optional, requires API key)
- Batch geocoding with parallel processing
- Input cleaning and coordinate validation
- Provider usage statistics
- Separate function for postal code geocoding
Installation
pip install .
Usage
from robust_geocoder import GeocodeFallback
# Initialize for Sri Lanka
geocoder = GeocodeFallback(country_code='LK', bounds=(5.9, 9.9, 79.5, 82.0))
# Single location (city/district)
result = geocoder.geocode_location("Colombo", verbose=True)
# Batch geocoding
locations = [
{'location': 'Colombo', 'district': 'Colombo'},
{'location': 'Kandy', 'district': 'Kandy'},
]
results = geocoder.geocode_batch(locations, num_threads=4, verbose=True)
# Postal code lookup (returns coordinates for valid postal codes)
postal_result = geocoder.geocode_postal_code("00100")
print(postal_result)
Requirements
- pandas
- pgeocode
- requests
- python-dotenv
- geopy
- SPARQLWrapper (optional, for Wikidata)
- duckduckgo-search (optional, for DuckDuckGo)
Environment Variables
SERPER_API_KEY(optional, for Serper API)
License
MIT
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
robust_geocoder-0.1.0.tar.gz
(9.1 kB
view details)
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file robust_geocoder-0.1.0.tar.gz.
File metadata
- Download URL: robust_geocoder-0.1.0.tar.gz
- Upload date:
- Size: 9.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c2ebd5f97a19d0493696dc317901b490f80fb284ce1fa837256fbbe73fee9189
|
|
| MD5 |
99ef17b5d3d1810ec6c683a8e2991497
|
|
| BLAKE2b-256 |
f27e3ee564dbd51f8dbb7eb21df959a28f65a488b7a378d6f990e173c3a5eb16
|
File details
Details for the file robust_geocoder-0.1.0-py3-none-any.whl.
File metadata
- Download URL: robust_geocoder-0.1.0-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.12.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
26464d0b5753ef8c977b9e57544cd6e6ea53e6d3c8c1029b7e6b53bcbfd2911f
|
|
| MD5 |
215277b4079b9d06995244e17bda8602
|
|
| BLAKE2b-256 |
b9615bb267fc4e466feb110bede129f96c0b022bbe52588a544d82009f952710
|