Skip to main content

geonames_postcode is a Python package to make geonames.org postcode databases accessible in Python. It provides a command line tool to fetch, preprocess, and store the data in a Python file per country. In the result very fast (in-memory) queries by postcodes and names are available using just a few MB per country. Some helper functions are part of the package to solve common tasks like getting distances and finding postcodes nearby.

Project description

geonames_postcode is a Python package to make geonames.org postcode databases accessible in Python. It provides a command line tool to fetch, preprocess, and store the data in a Python file per country. In the result very fast (in-memory) queries by postcodes and names are available using just a few MB per country. Some helper functions are part of the package to solve common tasks like getting distances and finding postcodes nearby.

Quickstart

Please respect the license of the geonames.org data (Creative Commons Attribution 4.0 License), see geonames.org for details.

On the console:

pip install geonames_postcode
geonames_postcode_fetch DE

In Python:

>>> import geonames_postcode
>>> latlong1 = geonames_postcode.coordinates('DE', 'Unterschleißheim')
>>> latlong1
(48.2804, 11.5768)
>>> latlong2 = geonames_postcode.coordinates('DE', 'München')
>>> geonames_postcode.distance(*latlong1, *latlong2)
15.289746063637923
>>> geonames_postcode.nearby_postcodes('DE', *latlong1, 5)
['85386', '85716', '85764', '85778']
>>> geonames_postcode.postcode_names('DE', '85764')
['Oberschleißheim']
>>> geonames_postcode.name_autocomplete('DE', 'Münche')
['München', 'Müncheberg', 'Münchehofe', 'Münchenbernsdorf']

Usage

see https://geonames-postcode.readthedocs.io/

License

The project is licensed under the GPLv2+.

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

geonames_postcode-0.3.tar.gz (17.9 kB view details)

Uploaded Source

File details

Details for the file geonames_postcode-0.3.tar.gz.

File metadata

  • Download URL: geonames_postcode-0.3.tar.gz
  • Upload date:
  • Size: 17.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.5

File hashes

Hashes for geonames_postcode-0.3.tar.gz
Algorithm Hash digest
SHA256 144e7aa025aed012f212919ffc227d18073afdd7261e159caa7df660e4795c25
MD5 c078c97e088b7e8dd82eb47f5617fdc6
BLAKE2b-256 846ad2f2d4c1d21d5dc784bc094406622b0c724bbdfbd621a86decf1fa2a2251

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