Skip to main content

pluscodes

An implementation of Google's Open Location Code algorithm forked from the openlocationcode==1.0.1 package.

Motivation

The Python implementation of Google's Open Location Code is not particularly Pythonic with respect to its naming conventions. The core code is in both openlocationcode and this package are pure Python with no dependencies outside of the standard library.

We hope to presents geocoordinates using a more consistent API. A longer term goal to more efficiently handle bulk Plus Code assignments and further more readily enable Plus Code lookup and categorization.

Installation

This package is available in PyPi, so simply

pip install pluscodes

Usage

The PlusCode constructor provides the main entry point for generating the string Plus Code (encoding) and geographic area boundary ("decoding").

from pluscodes import PlusCode, Area, Point

googleplex = PlusCode(37.4223041570954, -122.08410042965134)

assert googleplex.code == '849VCWC8+W9'

# Get the geocoordinate bounds for the length 10 Plus Code area.
assert googleplex.area == Area(
    sw=Point(lat=37.42225, lon=-122.084125),
    ne=Point(lat=37.422375, lon=-122.084),
)

# Decode a Plus Code into a geographic region.
r_googleplex = PlusCode('849VCWC8+W9')

assert googleplex.code == r_googleplex.code
assert googleplex.area == r_googleplex.area

This package also provides the original openlocationcode==1.0.1 package as a subpackage for use-cases that wish to adhere to openlocationcode's API.

import pluscodes
from pluscodes import openlocationcode

expected_code = '6FG22222+22'
plus = pluscodes.encode(0.0, 0.0)
olc = openlocationcode.encode(0.0, 0.0)

assert (plus == expected_code) and (olc == expected_code)

print(openlocationcode.decode('6FG22222+22'))
# [0.0, 0.0, 0.000125, 0.000125, 6.25e-05, 6.25e-05, 10]

print(pluscodes.decode('6FG22222+22'))
# Area(sw=Point(lat=0.0, lon=0.0), ne=Point(lat=0.000125, lon=0.000125))

Differences from openlocationcode

This package does not automatically validate or normalize inputs. For example, it is assumed that all latitude values are in [-90, 90] and all longitude values are in [-180, 180].

Moreover, the encoding and decoding APIs are combined in the PlusCode class, with the decoding API producing a simple dataclass consisting of two Point instances.

Metadata

Release files for pluscodes 2022.1.3

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

Built distribution (wheel)

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

Release files / pluscodes-2022.1.3-py3-none-any.whl

Download URL pluscodes-2022.1.3-py3-none-any.whl
Size 25.0 kB
Tags Python 3
SHA-256 checksum
How to use checksums
50625f472f8d4e8822e005180c2eb41bf09e45e429f362d3cded346f1169dae8
BLAKE2b-256 checksum
How to use checksums
229be3ac5854baae4e776bef43e440d897d32c1e5f3384ae27609248cec5f300
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/4.0.1 CPython/3.10.6

Release history Release notifications | RSS feed

This release

2022.1.3 This release

1 release file

0.1.0

1 release file

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