Skip to main content

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.

Metadata

Release files for maidenhead 1.8.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for maidenhead 1.8.0
File Size Uploaded
maidenhead-1.8.0.tar.gz 8.8 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for maidenhead 1.8.0
File Interpreter ABI Platform
maidenhead-1.8.0-py3-none-any.whl Python 3 none any Details

Total release size: 18.1 kB

Release files / maidenhead-1.8.0.tar.gz

Download URL maidenhead-1.8.0.tar.gz
Size 8.8 kB
Tags Source
SHA-256 checksum
How to use checksums
38f318fbdf29ec995bd45e81f33bfa1f905129a154f0aa0334452f90e6c705bf
BLAKE2b-256 checksum
How to use checksums
3a8e57498adbd28d3e1a877f7f0498d84a02ff9f607ea5c36c365c84a97bd77b
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 25, 2025.

Transparency log

Release files / maidenhead-1.8.0-py3-none-any.whl

Download URL maidenhead-1.8.0-py3-none-any.whl
Size 9.3 kB
Tags Python 3
SHA-256 checksum
How to use checksums
ddc33fb370e0c3ce917be6040474ecb4c27ccc33b3dc9348536b73b5884bb68a
BLAKE2b-256 checksum
How to use checksums
6082167553db9cff18f759048f6d90bf8348bae7b24c652dc2fbae6f87fa8a66
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/6.1.0 CPython/3.12.9

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on May 25, 2025.

Transparency log

Release history Release notifications | RSS feed

This release

1.8.0 This release

2 release files

1.7.0

1 release file

1.6.0

1 release file

1.5.0

1 release file

1.4.1

1 release file

1.4.0

1 release file

1.3.0

1 release file

1.2.1

1 release file

1.2.0

1 release file

1.1.6

2 release files

1.1.5

2 release files

1.1.4

2 release files

1.1.3

2 release files

1.1.2

2 release files

1.1.1

2 release files

1.1.0

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page