skillfed

pypolyline

Fast Google Polyline encoding and decoding using Rust FFI

pypolyline v0.5.8 105.6K downloads/30d#12,691 on PyPI45
License unclear BlueOak-1.0.0 Active released

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 pypolyline

uv

uv add pypolyline

poetry

poetry add pypolyline

Installing 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

Development Status :: 5 - Production/StableIntended Audience :: DevelopersIntended Audience :: EducationIntended Audience :: Science/ResearchOperating System :: OS IndependentProgramming Language :: PythonProgramming Language :: Python :: 3.10Programming Language :: Python :: 3.11Programming Language :: Python :: 3.12Programming Language :: Python :: 3.13Programming Language :: Python :: 3.14Topic :: Scientific/Engineering :: GISTopic :: Software Development :: Libraries :: Python Modules

Tags

polyline encoding decodinggoogle maps polylinecoordinate compressiongeospatial data compressionroute encodinglatitude longitude encodingmap route serialization
geospatialmappingperformance-critical

More Python Modules packages