Skip to main content

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:
    1. Geopy Nominatim (OpenStreetMap)
    2. Wikidata SPARQL
    3. Photon API
    4. DuckDuckGo Instant Answer (free)
    5. 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


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)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

robust_geocoder-0.1.0-py3-none-any.whl (8.9 kB view details)

Uploaded Python 3

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

Hashes for robust_geocoder-0.1.0.tar.gz
Algorithm Hash digest
SHA256 c2ebd5f97a19d0493696dc317901b490f80fb284ce1fa837256fbbe73fee9189
MD5 99ef17b5d3d1810ec6c683a8e2991497
BLAKE2b-256 f27e3ee564dbd51f8dbb7eb21df959a28f65a488b7a378d6f990e173c3a5eb16

See more details on using hashes here.

File details

Details for the file robust_geocoder-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for robust_geocoder-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 26464d0b5753ef8c977b9e57544cd6e6ea53e6d3c8c1029b7e6b53bcbfd2911f
MD5 215277b4079b9d06995244e17bda8602
BLAKE2b-256 b9615bb267fc4e466feb110bede129f96c0b022bbe52588a544d82009f952710

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page