{"id":15442507,"url":"https://github.com/cheginit/catsmoothing","last_synced_at":"2026-02-22T07:13:26.781Z","repository":{"id":257801733,"uuid":"862680217","full_name":"cheginit/catsmoothing","owner":"cheginit","description":"Smoothing Shapely Geometries with Catmull-Rom Splines","archived":false,"fork":false,"pushed_at":"2024-10-01T19:42:56.000Z","size":827,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2024-10-18T12:56:38.062Z","etag":null,"topics":["interpolation","python","shapely","smoothing","spline"],"latest_commit_sha":null,"homepage":"https://catsmoothing.readthedocs.io","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/cheginit.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":"CODE_OF_CONDUCT.md","threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":"AUTHORS.md","dei":null,"publiccode":null,"codemeta":null},"funding":{"github":["cheginit"]}},"created_at":"2024-09-25T02:28:26.000Z","updated_at":"2024-10-04T15:50:51.000Z","dependencies_parsed_at":null,"dependency_job_id":"4f01be11-48e1-474c-9538-e7c6d5bb3ceb","html_url":"https://github.com/cheginit/catsmoothing","commit_stats":{"total_commits":30,"total_committers":2,"mean_commits":15.0,"dds":"0.033333333333333326","last_synced_commit":"ef2f4d008495ad9bb7c358ca087d30b9dacca313"},"previous_names":["cheginit/catsmoothing"],"tags_count":4,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheginit%2Fcatsmoothing","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheginit%2Fcatsmoothing/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheginit%2Fcatsmoothing/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/cheginit%2Fcatsmoothing/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/cheginit","download_url":"https://codeload.github.com/cheginit/catsmoothing/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":241587784,"owners_count":19986628,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["interpolation","python","shapely","smoothing","spline"],"created_at":"2024-10-01T19:28:12.599Z","updated_at":"2026-02-22T07:13:26.775Z","avatar_url":"https://github.com/cheginit.png","language":"Python","funding_links":["https://github.com/sponsors/cheginit"],"categories":[],"sub_categories":[],"readme":"![CatSmoothing](https://raw.githubusercontent.com/cheginit/catsmoothing/refs/heads/main/docs/assets/logo_small.png)\n\n# CatSmoothing: Smoothing Shapely Geometries with Catmull-Rom Splines\n\n[![PyPI](https://img.shields.io/pypi/v/catsmoothing)](https://pypi.org/project/catsmoothing/)\n[![Conda](https://img.shields.io/conda/vn/conda-forge/catsmoothing)](https://anaconda.org/conda-forge/catsmoothing)\n[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)\n[![Binder](https://mybinder.org/badge_logo.svg)](https://mybinder.org/v2/gh/cheginit/catsmoothing/HEAD?labpath=docs%2Fexamples)\n[![Downloads](https://img.shields.io/conda/dn/conda-forge/catsmoothing.svg)](https://anaconda.org/conda-forge/catsmoothing)\n\n[![codecov](https://codecov.io/gh/cheginit/catsmoothing/graph/badge.svg?token=U2638J9WKM)](https://codecov.io/gh/cheginit/catsmoothing)\n[![CI](https://github.com/cheginit/catsmoothing/actions/workflows/test.yml/badge.svg)](https://github.com/cheginit/catsmoothing/actions/workflows/test.yml)\n[![Documentation Status](https://readthedocs.org/projects/catsmoothing/badge/?version=latest)](https://catsmoothing.readthedocs.io/latest/?badge=latest)\n[![Ruff](https://img.shields.io/endpoint?url=https://raw.githubusercontent.com/astral-sh/ruff/main/assets/badge/v2.json)](https://github.com/astral-sh/ruff)\n[![CodSpeed Badge](https://img.shields.io/endpoint?url=https://codspeed.io/badge.json)](https://codspeed.io/cheginit/catsmoothing)\n\n## Overview\n\n**CatSmoothing** smooths [Shapely](https://shapely.readthedocs.io) geometries,\n`LineString` and `(Multi)Polygon`, using the Catmull-Rom spline algorithm and can\ncompute tangent angles at each vertex of a list of lines. The implementation is based on\nthe [Splines](https://github.com/AudioSceneDescriptionFormat/splines) library, but\noffers performance improvements and additional features.\n\nYou can try CatSmoothing directly in your browser by clicking the Binder badge above.\n\n## Key Features\n\n- Written in Rust for performance and runs in parallel using Rayon\n- Creating splines from 2D/3D vertices of a line that allows computing n-th derivatives\n- Smoothing geometries with Centripetal Catmull-Rom splines with **uniform spacing**\n    (spacing is determined iteratively based on the arc length of the input geometry)\n- Computing tangent vectors at each vertex of a line\n- Optional Gaussian filtering to reduce noise in input geometries before smoothing\n\n## Installation\n\nInstall CatSmoothing via `pip` or `micromamba`:\n\nUsing `pip`:\n\n```bash\npip install catsmoothing\n```\n\nUsing `micromamba` (or `conda`/`mamba`):\n\n```bash\nmicromamba install -c conda-forge catsmoothing\n```\n\n## Quick Start\n\nCatSmoothing provide one class called `CatmullRom` that is general purpose, Catmull-Rom\nspline interpolation class. You can tweak the `alpha` parameter of the class to\ninterpolate with different versions of the Catmull-Rom spline from 2D/3D vertices of a\nline and compute n-th derivatives. For smoothing geometries, CatSmoothing uses the\ncentripetal Catmull-Rom spline algorithm, i.e., `alpha=0.5`. There are two functions\nthat can be used for smoothing geometries: `smooth_linestrings` and `smooth_polygon`.\nThere is also a function for computing tangent angles (in radians) at each vertex of a\nline.\n\n### Basic Usage\n\nFor fitting a Catmull-Rom spline to a line, we can use the following code:\n\n```python\nfrom catsmoothing import CatmullRom\n\n\nverts = [(0, 0), (0, 0.5), (1.5, 1.5), (1.6, 1.5), (3, 0.2), (3, 0)]\nn_pts = 15\nsmoothed = {}\nfor alpha in (0, 0.5, 1):\n    s = CatmullRom(verts, alpha=alpha, bc_type=\"closed\")\n    dots = int((s.grid[-1] - s.grid[0]) * n_pts) + 1\n    distances = s.grid[0] + np.arange(dots) / n_pts\n    smoothed[alpha] = s.evaluate(distances)\n```\n\n![Catmull-Rom Splines](https://raw.githubusercontent.com/cheginit/catsmoothing/main/docs/examples/images/alpha.png)\n\nFor smoothing a geometry, we can use the following code:\n\n```python\nfrom shapely import Polygon\nimport catsmoothing as cs\n\n\npoly = Polygon(verts)\nploy_smoothed = cs.smooth_polygon(poly, n_pts=50)\n```\n\n![Polygon Smoothing](https://raw.githubusercontent.com/cheginit/catsmoothing/main/docs/examples/images/poly.png)\n\nFor smoothing a noisy line, we can use the following code:\n\n```python\nimport numpy as np\nfrom shapely import LineString\nimport catsmoothing as cs\n\n\nrng = np.random.default_rng(123)\nx = np.linspace(-3, 2.5, 50)\ny = np.exp(-(x**2)) + 0.1 * rng.standard_normal(50)\nline = LineString(np.c_[x, y])\nline_smoothed = cs.smooth_linestrings(line, n_pts=30, gaussian_sigmas=2)\n```\n\n![Line Smoothing](https://raw.githubusercontent.com/cheginit/catsmoothing/main/docs/examples/images/line.png)\n\nWe can then compute the tangent angles in radians at each vertex of the smoothed line:\n\n```python\ntangents = cs.linestrings_tangent_angles(line_smoothed)\n```\n\n![Tangent Angles](https://raw.githubusercontent.com/cheginit/catsmoothing/main/docs/examples/images/tangents.png)\n\nFor more examples, visit the [documentation](https://catsmoothing.readthedocs.io).\n\n## Contributing\n\nWe welcome contributions! For guidelines, please refer to the\n[CONTRIBUTING.md](https://catsmoothing.readthedocs.io/latest/CONTRIBUTING) and\n[CODE_OF_CONDUCT.md](https://github.com/cheginit/catsmoothing/blob/main/CODE_OF_CONDUCT.md).\n\n## License\n\nCatSmoothing is licensed under the MIT License. See the\n[LICENSE](https://github.com/cheginit/catsmoothing/blob/main/LICENSE) file for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheginit%2Fcatsmoothing","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcheginit%2Fcatsmoothing","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcheginit%2Fcatsmoothing/lists"}