All Projects → Placekey → placekey-py

Placekey / placekey-py

Licence: Apache-2.0 license
placekey.io

Programming Languages

python
139335 projects - #7 most used programming language
Batchfile
5799 projects
Makefile
30231 projects

Projects that are alternatives of or similar to placekey-py

placekey-js
placekey.io
Stars: ✭ 19 (-61.22%)
Mutual labels:  h3, geospatial, placekey
geodesy-php
Geodesy PHP - Port of some known geodesic/math functions for getting distance from a known point A to a known point B given their coordinates. It also supports conversion between units of length, Polar position to Cartesian coordinates, and different Reference Datums.
Stars: ✭ 26 (-46.94%)
Mutual labels:  distance, geospatial
H3.net
Port of Uber's H3 to .NET
Stars: ✭ 27 (-44.9%)
Mutual labels:  h3, geospatial
h3-r
R bindings for H3, a hierarchical hexagonal geospatial indexing system
Stars: ✭ 57 (+16.33%)
Mutual labels:  h3, geospatial
Cheap Ruler Go
📏 cheapruler in Go: fast geodesic measurements
Stars: ✭ 176 (+259.18%)
Mutual labels:  distance, geospatial
h3ron
Rust crates for the H3 geospatial indexing system
Stars: ✭ 52 (+6.12%)
Mutual labels:  h3, geospatial
H3
Hexagonal hierarchical geospatial indexing system
Stars: ✭ 3,167 (+6363.27%)
Mutual labels:  h3, geospatial
Spatial-Analysis-Mapping-Projects
Project Documentation, Best Practices & Procedures for Spatial Analysis and Mapping Projects
Stars: ✭ 15 (-69.39%)
Mutual labels:  geospatial
ndjson
ndjson with the same interface as the builtin json module
Stars: ✭ 59 (+20.41%)
Mutual labels:  pypi
mf-chsdi3
api3.geo.admin.ch source code.
Stars: ✭ 35 (-28.57%)
Mutual labels:  geospatial
craft
The universal Sentry release CLI 🚀
Stars: ✭ 117 (+138.78%)
Mutual labels:  pypi
caffe weight converter
Caffe-to-Keras weight converter. Can also export weights as Numpy arrays for further processing.
Stars: ✭ 68 (+38.78%)
Mutual labels:  conversion
hera-workflows
Hera is an Argo Workflows Python SDK. Hera aims to make workflow construction and submission easy and accessible to everyone! Hera abstracts away workflow setup details while still maintaining a consistent vocabulary with Argo Workflows.
Stars: ✭ 252 (+414.29%)
Mutual labels:  pypi
pmm
PyPi Mirror Manager
Stars: ✭ 29 (-40.82%)
Mutual labels:  pypi
vectorexpress-api
Vector Express is a free service and API for converting, analyzing and processing vector files.
Stars: ✭ 66 (+34.69%)
Mutual labels:  conversion
django-freeze
🧊 convert your dynamic django site to a static one with one line of code.
Stars: ✭ 81 (+65.31%)
Mutual labels:  pypi
krawler
A minimalist (geospatial) ETL
Stars: ✭ 51 (+4.08%)
Mutual labels:  geospatial
sms
A Go library for encoding and decoding SMSs
Stars: ✭ 37 (-24.49%)
Mutual labels:  conversion
geometry-library
PHP Geometry Library provides utility functions for the computation of geometric data on the surface of the Earth. Code ported from Google Maps Android API.
Stars: ✭ 132 (+169.39%)
Mutual labels:  distance
shell2batch
Coverts simple basic shell scripts to windows batch scripts.
Stars: ✭ 42 (-14.29%)
Mutual labels:  conversion

Placekey-py

PyPI version PyPI downloads version

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 Plackey design specification is available here. The details in Placekey encoding is here. We welcome your feedback.

Installation

This package can be installed from PyPI by

pip install placekey

MacOS Big Sur may need to run brew install geos if the installation of the shapely dependency fails.

Usage

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)
'@dvt-smp-tvz'
>>> 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')
'8a754e64992ffff'
>>> pk.h3_to_placekey('8a754e64992ffff')
'@dvt-smp-tvz'

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

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

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')
True
>>> pk.placekey_format_is_valid('@123-456-789')
False

API Client

This package also includes a client for the Placekey API. The methods in the client are automatically rate limited.

>>> from placekey.api import PlacekeyAPI
>>> placekey_api_key = "..."
>>> pk_api = PlacekeyAPI(placekey_api_key)

The PlacekeyAPI.lookup_placekey method can be used to lookup the Placekey for a single place.

>>> pk_api.lookup_placekey(latitude=37.7371, longitude=-122.44283)
{'query_id': '0', 'placekey': '@5vg-82n-kzz'}
>>> place = {
>>>   "street_address": "598 Portola Dr",
>>>   "city": "San Francisco",
>>>   "region": "CA",
>>>   "postal_code": "94131",
>>>   "iso_country_code": "US"
>>> }
>>> pk_api.lookup_placekey(**place, strict_address_match=True)
{'query_id': '0', 'placekey': '227@5vg-82n-pgk'}

The PlacekeyAPI.lookup_placekeys method can be used to lookup Placekeys for multiple places.

>>> places = [
>>>   {
>>>     "street_address": "1543 Mission Street, Floor 3",
>>>     "city": "San Francisco",
>>>     "region": "CA",
>>>     "postal_code": "94105",
>>>     "iso_country_code": "US"
>>>   },
>>>   {
>>>     "query_id": "thisqueryidaloneiscustom",
>>>     "location_name": "Twin Peaks Petroleum",
>>>     "street_address": "598 Portola Dr",
>>>     "city": "San Francisco",
>>>     "region": "CA",
>>>     "postal_code": "94131",
>>>     "iso_country_code": "US"
>>>   },
>>>   {
>>>     "latitude": 37.7371,
>>>     "longitude": -122.44283
>>>   }
>>> ]
>>> pk_api.lookup_placekeys(places)
[{'query_id': 'place_0', 'placekey': '226@5vg-7gq-5mk'},
 {'query_id': 'thisqueryidaloneiscustom', 'placekey': '227-222@5vg-82n-pgk'},
 {'query_id': 'place_2', 'placekey': '@5vg-82n-kzz'}]

Full details on how to query the API and how to get an API key can be found here.

Notebooks

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

Support

This package runs on Python 3.

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].