Skip to main content

Maidenhead Locator, Lat Lon coordinate convertor

Project description

Maidenhead <-> Lat/Lon

DOI ci pypi versions PyPi Download stats

maidenhead provides a simple, yet effective location hashing algorithm. Maidenhead allows global location precision down to 750m

Maidenhead provides 4 levels of increasing accuracy

Level Precision
1 World
2 Regional
3 Metropolis
4 City
5 Street
6 1m precision
pip install maidenhead

or for development version

git clone https://github.com/space-physics/maidenhead

pip install -e maidenhead

Examples assume first doing

import maidenhead as mh

Lat, lon to Maidenhead locator:

mh.to_maiden(lat, lon, level)

returns a char (len = lvl*2)

Maidenhead locator to lat lon:

mh.to_location('AB01cd')

takes Maidenhead location string and returns top-left lat, lon of Maidenhead grid square.

The center=True option outputs lat lon of the center of provided maidenhead grid square, instead of the default southwest corner.

Maidenhead locator to geoJSON (RFC 7946)

geo_obj = mh.to_geoJSONObject('AB01cd', center=True, nosquare=False)
geoJSON = json.dumps(geo_obj, indent=2)

Command Line

The command line interface takes either decimal degrees for "latitude longitude" or the Maidenhead locator string:

python -m maidenhead 65.0 -148.0

BP65aa

python -m maidenhead BP65aa12

65.0083 -147.9917

The "python -m" CLI is also available:

python -m maidenhead 65.0 -148.0

The --center option outputs lat lon of the center of provided maidenhead grid square, instead of the default southwest corner.

python -m maidenhead --center --geojson EN35ld

{"type": "FeatureCollection", "features": [{"type": "Feature", "properties": {"QTHLocator_Centerpoint": "EN35ld"}, "geometry": {"type": "Point", "coordinates": [-93.04166666666667, 45.145833333333336]}}, {"type": "Feature", "properties": {"QTHLocator": "EN35ld"}, "geometry": {"type": "Polygon", "coordinates": [[[-93.08333333333333, 45.125], [-93.08333333333333, 45.166666666666664], [-93.0, 45.166666666666664], [-93.0, 45.125], [-93.08333333333333, 45.125]]]}}]}

The --center option enables adding center point of the grid square as Point feature.

The --nosquare option disables adding Polygon feature for the requested grid square

Alternatives

Open Location Codes a.k.a Plus Codes are in Python code by Google.

Web convertor Earth Point - Tools for Google Earth.

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

maidenhead-1.8.0.tar.gz (8.8 kB view details)

Uploaded Source

Built Distribution

maidenhead-1.8.0-py3-none-any.whl (9.3 kB view details)

Uploaded Python 3

File details

Details for the file maidenhead-1.8.0.tar.gz.

File metadata

  • Download URL: maidenhead-1.8.0.tar.gz
  • Upload date:
  • Size: 8.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maidenhead-1.8.0.tar.gz
Algorithm Hash digest
SHA256 38f318fbdf29ec995bd45e81f33bfa1f905129a154f0aa0334452f90e6c705bf
MD5 409d8ea4071380f2ce4a95a7716e6803
BLAKE2b-256 3a8e57498adbd28d3e1a877f7f0498d84a02ff9f607ea5c36c365c84a97bd77b

See more details on using hashes here.

Provenance

The following attestation bundles were made for maidenhead-1.8.0.tar.gz:

Publisher: publish-python-package.yml on space-physics/maidenhead

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file maidenhead-1.8.0-py3-none-any.whl.

File metadata

  • Download URL: maidenhead-1.8.0-py3-none-any.whl
  • Upload date:
  • Size: 9.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for maidenhead-1.8.0-py3-none-any.whl
Algorithm Hash digest
SHA256 ddc33fb370e0c3ce917be6040474ecb4c27ccc33b3dc9348536b73b5884bb68a
MD5 3bb43fcb269a67f65048ec38e760f64c
BLAKE2b-256 6082167553db9cff18f759048f6d90bf8348bae7b24c652dc2fbae6f87fa8a66

See more details on using hashes here.

Provenance

The following attestation bundles were made for maidenhead-1.8.0-py3-none-any.whl:

Publisher: publish-python-package.yml on space-physics/maidenhead

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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