{"id":10122,"library":"pypolyline","title":"pypolyline","description":"pypolyline provides fast Google Polyline encoding and decoding functionalities, leveraging Rust FFI for performance. It is currently at version 0.5.6 and maintains an active, albeit irregular, release cadence with minor updates addressing improvements and bug fixes.","status":"active","version":"0.5.6","language":"en","source_language":"en","source_url":"https://github.com/urschrei/pypolyline","tags":["GIS","mapping","polyline","encoding","decoding","geospatial"],"install":[{"cmd":"pip install pypolyline","lang":"bash","label":"Install with pip"}],"dependencies":[],"imports":[{"symbol":"decode","correct":"from pypolyline.codec import decode"},{"symbol":"encode","correct":"from pypolyline.codec import encode"}],"quickstart":{"code":"from pypolyline.codec import decode, encode\n\n# Example data\ntest_polyline = \"y~z_@mfhV~tqNvxq`@\"\ntest_points = [(38.5, -120.2), (40.7, -120.95), (43.252, -126.453)]\n\n# Encoding points to a polyline string (Google Polyline typically uses precision=5)\nencoded_polyline = encode(test_points, precision=5)\nprint(f\"Encoded Polyline: {encoded_polyline}\")\n\n# Decoding a polyline string back to points\ndecoded_points = decode(test_polyline, precision=5)\nprint(f\"Decoded Points: {decoded_points}\")","lang":"python","description":"This quickstart demonstrates how to encode a list of (latitude, longitude) tuples into a Google Polyline string and decode a Polyline string back into a list of points. The `precision` parameter is crucial for correct encoding/decoding, with `5` being standard for Google Polylines."},"warnings":[{"fix":"Replace `factor=1e5` (or similar) with `precision=5` (or the corresponding precision) in your calls to `encode` and `decode`.","message":"The `factor` argument for `encode` and `decode` functions was replaced by `precision` in `v0.5.0`. Using `factor` will now raise a TypeError.","severity":"breaking","affected_versions":">=0.5.0"},{"fix":"Ensure you have a Rust toolchain installed (e.g., using `rustup`) if `pip install pypolyline` fails with compiler-related errors. Alternatively, try to use a Python version/OS for which wheels are pre-built (Linux, macOS, Windows are generally well-supported).","message":"Installation via `pip` requires a Rust toolchain if a pre-built wheel is not available for your specific Python version and operating system combination.","severity":"gotcha","affected_versions":"All versions"},{"fix":"For standard Google Polylines, always use `precision=5`. If working with custom polyline specifications, ensure the `precision` matches the expected decimal places of the coordinate components.","message":"Using an incorrect `precision` value will lead to inaccurate decoded points or unnecessarily long (overly precise) encoded polylines.","severity":"gotcha","affected_versions":"All versions"}],"env_vars":null,"last_verified":"2026-04-17T00:00:00.000Z","next_check":"2026-07-16T00:00:00.000Z","problems":[{"fix":"Install Rust by following instructions on https://rustup.rs (e.g., `curl --proto '=https' --tlsv1.2 -sSf https://sh.rustup.rs | sh`) and then retry `pip install pypolyline`.","cause":"During `pip install pypolyline`, a pre-built wheel for your platform/Python version was not found, and `pip` attempted to build the library from source without an installed Rust toolchain.","error":"error: can't find Rust compiler"},{"fix":"Replace `factor=...` with `precision=...`. For example, `factor=1e5` should become `precision=5`.","cause":"You are attempting to use the `factor` argument, which was deprecated and removed in `pypolyline` `v0.5.0` in favor of `precision`.","error":"TypeError: encode() got an unexpected keyword argument 'factor'"},{"fix":"Verify that `precision=5` is used for standard Google Polylines, as this specifies a factor of 10^5. Adjust `precision` if your polyline format uses a different scaling factor.","cause":"The `precision` parameter used during encoding or decoding does not match the expected precision for the polyline data.","error":"Decoded points are not accurate (e.g., missing decimal places) or encoded polyline is much shorter/longer than expected."}]}