polyline
A Python implementation of Google's Encoded Polyline Algorithm Format.
What it is and what it does
Polyline is a Python implementation of Google's Encoded Polyline Algorithm Format, a standard method for compressing sequences of latitude/longitude coordinates into a compact string representation. It converts between human-readable coordinate tuples and the compressed format used by mapping APIs, supporting both (lat, lon) and GeoJSON (lon, lat) coordinate orders. The package has no runtime dependencies and works with Python 3.8 and above.
Typically used in mapping and geolocation applications to reduce bandwidth when transmitting routes, paths, or coordinate sequences over the network. You provide a list of coordinate pairs and a precision level, and the encoder produces a compressed string; the decoder reverses the process. The library is a port of Mapbox's polyline implementation with additional features, making it suitable for applications that need to serialize geographic data efficiently.
Use it for:
- Compress GPS route data for transmission to mapping APIs or storage in databases.
- Decode polyline strings returned by Google Maps or other mapping services into coordinate lists.
- Reduce payload size when sending coordinate sequences over HTTP in web or mobile applications.
- Convert between coordinate formats (lat/lon vs. GeoJSON) for compatibility with different mapping libraries.
- Encode walking or driving routes for display on interactive maps with minimal data transfer.
Worth the install?
AI-flagged interpretation of the facts on this page — verify before relying
Encodes and decodes geographic coordinate sequences using Google's Encoded Polyline Algorithm Format, converting between (lat, lon) tuples and compressed polyline strings.
Yes, if you need to work with Google's Encoded Polyline format. The package is lightweight, dependency-free, and widely used (top 5000 on PyPI). Maintenance is aging but the code is stable and no vulnerabilities are known. The MIT license is permissive. Install it if your application requires polyline encoding/decoding; skip it if you don't work with this specific format.
Install
polyline on PyPI
pip
pip install polylineuv
uv add polylinepoetry
poetry add polylineInstalling polyline
Before you install
Low install friction with no runtime dependencies. Maintenance status is aging—last release 255 days ago—but the repository remains active and the package has been stable since its 2014 inception.
License in practice
MIT license (inferred from license text). Permissive; you may use, modify, and distribute freely with attribution and without warranty.
Quickstart
pip install polyline
import polyline
# Encode coordinates to polyline string
encoded = polyline.encode([(38.5, -120.2), (40.7, -120.9), (43.2, -126.4)], 5)
# Decode polyline string back to coordinates
decoded = polyline.decode('u{~vFvyys@fS]', 5)
Requires Python 3.8 or above; Python 2 is not supported in v2.0.4.
Verify before relying
- Whether the package handles edge cases (e.g., very large coordinate sets, extreme precision values) reliably.
- Performance characteristics for encoding/decoding large polyline datasets.
- Whether geojson parameter behavior is fully documented and tested.
Package facts
| License | Copyright (c) 2023 Frederick Jansen Copyright (c) 2014 Bruno M. Custódio Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation… (full text in the JSON record) (unclear) |
| Python support | supports the current Python release (>=3.8) |
| Install friction | low — pure-Python wheel |
| Runtime dependencies | none |
| Maintenance | aging — 255 days since the last release |
| Last repo commit | |
| First released | |
| Downloads | 2,499,132/month — #3,037 on PyPI (30-day window, as of 2026-08-14) |
| Known vulnerabilities | none known (OSV.dev, checked 2026-08-14) |
Evidence: polyline-2.0.4-py3-none-any.whl
Tags
More Utilities packages
Converts domain names between Unicode and…
permissive · top 100 on PyPI
charset-normalizerDetects and normalizes text encoding from…
permissive · top 100 on PyPI
setuptoolsSetuptools is a Python build backend and…
permissive · top 100 on PyPI
pluggyPluggy provides a plugin system that lets you…
permissive · top 100 on PyPI
PygmentsPygments is a syntax highlighter that colorizes…
permissive · top 100 on PyPI
sixSix provides utility functions to write Python…
permissive · top 100 on PyPI
flexpolylineEncodes and decodes geographic coordinate…
permissive · top 15,000 on PyPI
geobufGeobuf encodes GeoJSON to a compact binary…
permissive · top 15,000 on PyPI
topojsontopojson encodes spatial data into TopoJSON…
permissive · top 15,000 on PyPI
pypolylineEncodes and decodes Google Polyline format…
unclear · top 15,000 on PyPI
staticmapGenerates static map images with geographic…
unclear · top 15,000 on PyPI
python-geohashpython-geohash encodes and decodes geographic…
unclear · top 15,000 on PyPI
mapbox-vector-tileEncodes and decodes Mapbox Vector Tiles (MVT)…
permissive · top 15,000 on PyPI
searouteComputes the shortest sea route between two…
permissive · top 15,000 on PyPI
geolibEncodes and decodes geographic coordinates as…
permissive · top 15,000 on PyPI
lat-lon-parserParses latitude-longitude coordinate strings in…
permissive · top 15,000 on PyPI