pypolyline
Fast Google Polyline encoding and decoding using Rust FFI
What it is and what it does
Pypolyline is a Python wrapper around a Rust library that encodes and decodes the Google Polyline Algorithm format, which compresses sequences of latitude-longitude coordinates into a compact string representation. It is designed for mapping and geospatial applications where route data, GPS traces, or other coordinate sequences need to be efficiently stored or transmitted.
The package uses FFI (Foreign Function Interface) and Cython to call compiled Rust code, achieving significant speed improvements over pure-Python implementations. It depends only on numpy and provides two main functions: encode_coordinates() to compress coordinate arrays into polyline strings, and decode_polyline() to expand them back. Error handling raises RuntimeError with details on invalid input. The package supports all currently supported Python versions (3.10–3.14) across Linux, macOS, and Windows.
Use it for:
- Compress GPS traces or route data for storage in a database or API response.
- Encode map directions or navigation paths for transmission over bandwidth-constrained connections.
- Decode polyline strings from Google Maps API responses or other mapping services.
- Serialize coordinate sequences in web applications to reduce JSON payload size.
- Convert between different polyline precision levels (Google's 5 vs. OSRM/Valhalla's 6).
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Encodes and decodes Google Polyline format coordinates using Rust FFI, providing fast compression of latitude-longitude sequences for mapping applications.
Yes, if you work with polyline-encoded geographic data. The package is actively maintained, has no known vulnerabilities, supports current Python versions across major platforms, and delivers substantial performance gains over pure-Python alternatives. The only caveat is verifying that the Blue Oak 1.0.0 license fits your use case, and remembering that coordinates must be in (Longitude, Latitude) order.
Install
pypolyline on PyPI
pip
pip install pypolylineuv
uv add pypolylinepoetry
poetry add pypolylineInstalling pypolyline
Before you install
Medium install friction due to compiled wheels; prebuilt binaries available for Python 3.10–3.14 on Linux (x86_64, aarch64), macOS (x86_64, arm64), and Windows 64-bit. Last release 87 days ago; repository is active with recent commits.
License in practice
Licensed under Blue Oak Model Licence 1.0.0 (SPDX: BlueOak-1.0.0), a permissive open-source license. License treatment is marked unclear in metadata; verify terms directly in the LICENCE.md file if commercial use or redistribution is planned.
Quickstart
from pypolyline.cutil import encode_coordinates, decode_polyline
coords = [[52.64125, 23.70162], [52.64938, 23.70154]]
polyline = encode_coordinates(coords, 5)
decoded = decode_polyline(polyline, 5)
Coordinates must be in (Longitude, Latitude) order, not the more common (Latitude, Longitude). Precision parameter (5 for Google Polyline, 6 for OSRM/Valhalla) must be specified.
Verify before relying
- Whether Blue Oak 1.0.0 license is compatible with your project's licensing requirements or redistribution model.
- Performance characteristics on your specific hardware and coordinate dataset size relative to the M2 MBP benchmarks cited.
Package facts
| License | BlueOak-1.0.0 (unclear) |
| Python support | supports the current Python release (>=3.10) |
| Install friction | medium — platform-specific wheel |
| Runtime dependencies | 1 — numpy |
| Maintenance | actively maintained — 87 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 105,569/month — #12,691 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: pypolyline-0.5.8-cp310-cp310-macosx_11_0_arm64.whl; pypolyline-0.5.8-cp310-cp310-macosx_11_0_x86_64.whl; pypolyline-0.5.8-cp310-cp310-manylinux_2_28_aarch64.whl; pypolyline-0.5.8-cp310-cp310-manylinux_2_28_x86_64.whl; pypolyline-0.5.8-cp310-cp310-win_amd64.whl; pypolyline-0.5.8-cp311-cp311-macosx_11_0_arm64.whl; pypolyline-0.5.8-cp311-cp311-macosx_11_0_x86_64.whl; pypolyline-0.5.8-cp311-cp311-manylinux_2_28_aarch64.whl; pypolyline-0.5.8-cp311-cp311-manylinux_2_28_x86_64.whl; pypolyline-0.5.8-cp311-cp311-win_amd64.whl; pypolyline-0.5.8-cp312-cp312-macosx_11_0_arm64.whl; pypolyline-0.5.8-cp312-cp312-macosx_11_0_x86_64.whl; pypolyline-0.5.8-cp312-cp312-manylinux_2_28_aarch64.whl; pypolyline-0.5.8-cp312-cp312-manylinux_2_28_x86_64.whl; pypolyline-0.5.8-cp312-cp312-win_amd64.whl; pypolyline-0.5.8-cp313-cp313-macosx_11_0_arm64.whl; pypolyline-0.5.8-cp313-cp313-macosx_11_0_x86_64.whl; pypolyline-0.5.8-cp313-cp313-manylinux_2_28_aarch64.whl; pypolyline-0.5.8-cp313-cp313-manylinux_2_28_x86_64.whl; pypolyline-0.5.8-cp313-cp313-win_amd64.whl
Keywords: Geo, Polyline
Tags
More Python Modules packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
PyYAMLPyYAML parses and emits YAML 1.1 data format,…
permissive · top 100 on PyPI
pydanticPydantic validates Python data structures…
permissive · top 100 on PyPI
annotated-typesProvides reusable metadata objects for use with…
permissive · top 100 on PyPI
typing-inspectionProvides runtime tools to inspect and…
permissive · top 100 on PyPI
flexpolylineEncodes and decodes geographic coordinate…
permissive · top 15,000 on PyPI
polylineEncodes and decodes geographic coordinate…
unclear · top 5,000 on PyPI
geohash2Encodes latitude/longitude coordinates to…
agpl · top 5,000 on PyPI
pygeohashEncodes latitude/longitude coordinates to…
permissive · top 5,000 on PyPI
geobufGeobuf encodes GeoJSON to a compact binary…
permissive · top 15,000 on PyPI
pylzsspylzss decodes and encodes data compressed with…
copyleft · top 15,000 on PyPI
tzfpyConverts geographic coordinates…
permissive · top 5,000 on PyPI
convertbngConverts decimal WGS84 longitude/latitude…
unclear · top 15,000 on PyPI
simplificationSimplify LineStrings using the…
unclear · top 15,000 on PyPI
py-geohex3Converts between geographic coordinates…
permissive · top 15,000 on PyPI