Skip to main content
Join the official 2020 Python Developers SurveyStart the survey!

Utilities for working with Placekeys

Project description


A Python library for working with Placekeys. Documentation for this package can be found here, and documentation for the Placekey service API can be found here.


The basic functionality of the Placekey library is conversion between Placekeys and latitude-longitude coordinates.

>>> import placekey as pk
>>> lat, long = 0.0, 0.0
>>> pk.geo_to_placekey(lat, long)
>>> pk.placekey_to_geo('@dvt-smp-tvz')
(0.00018033323813810344, -0.00018985758738881587)

The library also allows for conversion between Placekeys and H3 indices.

>>> pk.placekey_to_h3('@dvt-smp-tvz')
>>> pk.h3_to_placekey('8a754e64992ffff')

The distance in meters between two Placekeys can be found with the following function.

>>> pk.placekey_distance('@dvt-smp-tvz', '@5vg-7gq-tjv')

An upper bound on the maximal distance in meters between two Placekeys based on the length of their shared prefix is provided by placekey.get_prefix_distance_dict().

>>> pk.get_prefix_distance_dict()
{0: 20040000.0,
 1: 20040000.0,
 2: 2777000.0,
 3: 1065000.0,
 4: 152400.0,
 5: 21770.0,
 6: 8227.0,
 7: 1176.0,
 8: 444.3,
 9: 63.47}

Placekeys found in a data set can be partially validated by

>>> pk.placekey_format_is_valid('222-227@dvt-smp-tvz')
>>> pk.placekey_format_is_valid('@123-456-789')


Jupyter notebooks demonstrating various Placekey functionality are contained in the placekey-notebooks repository.


This package runs on Python 3.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for placekey, version 0.0.4
Filename, size File type Python version Upload date Hashes
Filename, size placekey-0.0.4-py3-none-any.whl (10.1 kB) File type Wheel Python version py3 Upload date Hashes View
Filename, size placekey-0.0.4.tar.gz (5.6 kB) File type Source Python version None Upload date Hashes View

Supported by

Pingdom Pingdom Monitoring Google Google Object Storage and Download Analytics Sentry Sentry Error logging AWS AWS Cloud computing DataDog DataDog Monitoring Fastly Fastly CDN DigiCert DigiCert EV certificate StatusPage StatusPage Status page