Skip to main content

A Python implementation of Google's Encoded Polyline Algorithm Format.

Project description


polyline is a Python implementation of Google’s Encoded Polyline Algorithm Format ( It is essentially a port of built with Python 2 and 3 support in mind.


polyline can be installed using pip or easy_install:

$ pip install polyline
$ easy_install polyline

API Documentation


To get the encoded polyline representation of a given set of (lat, lon) coordinates:

import polyline
polyline.encode([(38.5, -120.2), (40.7, -120.9), (43.2, -126.4)], 5)

This should return _p~iF~ps|U_ulL~ugC_hgN~eq`@.

You can set the required precision with the optional precision parameter. The default value is 5.

You can encode (lon, lat) tuples by setting geojson=True.


To get a set of coordinates represented by a given encoded polyline string:

import polyline

This should return [(40.63179, -8.65708), (40.62855, -8.65693)] in (lat, lon) order.

You can decode into (lon, lat) tuples by setting geojson=True.

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Files for polyline, version 1.4.0
Filename, size File type Python version Upload date Hashes
Filename, size polyline-1.4.0-py2.py3-none-any.whl (4.4 kB) File type Wheel Python version py2.py3 Upload date Hashes View
Filename, size polyline-1.4.0.tar.gz (5.4 kB) File type Source Python version None Upload date Hashes View

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring DigiCert DigiCert EV certificate Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page