{"id":15442545,"url":"https://github.com/oreilles/polars-st","last_synced_at":"2025-04-07T13:04:14.298Z","repository":{"id":257789587,"uuid":"860345804","full_name":"Oreilles/polars-st","owner":"Oreilles","description":"Spatial extension for Polars DataFrames","archived":false,"fork":false,"pushed_at":"2025-04-06T15:05:49.000Z","size":1474,"stargazers_count":61,"open_issues_count":4,"forks_count":4,"subscribers_count":2,"default_branch":"main","last_synced_at":"2025-04-06T15:19:34.440Z","etag":null,"topics":["dataframe","geodataframe","geospatial","polars","python","rust","spatial"],"latest_commit_sha":null,"homepage":"https://oreilles.github.io/polars-st/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"lgpl-2.1","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/Oreilles.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"COPYING","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2024-09-20T09:07:04.000Z","updated_at":"2025-04-06T15:05:52.000Z","dependencies_parsed_at":"2025-03-23T09:24:15.073Z","dependency_job_id":"c2ee560c-480a-44e6-9ab2-cc5f73fbe451","html_url":"https://github.com/Oreilles/polars-st","commit_stats":{"total_commits":28,"total_committers":1,"mean_commits":28.0,"dds":0.0,"last_synced_commit":"ed5a2451289acd29cb7f897fcea20f57e619d29a"},"previous_names":["oreilles/polars-st"],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oreilles%2Fpolars-st","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oreilles%2Fpolars-st/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oreilles%2Fpolars-st/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/Oreilles%2Fpolars-st/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/Oreilles","download_url":"https://codeload.github.com/Oreilles/polars-st/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247639064,"owners_count":20971477,"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":["dataframe","geodataframe","geospatial","polars","python","rust","spatial"],"created_at":"2024-10-01T19:28:27.801Z","updated_at":"2025-04-07T13:04:14.291Z","avatar_url":"https://github.com/Oreilles.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"[![Banner](https://raw.githubusercontent.com/Oreilles/polars-st/main/assets/banner.svg)](#)\n\n# Polars ST\n\nPolars ST provides spatial operations on [Polars](https://github.com/pola-rs/polars) DataFrames, Series, and Expressions. Just like [Shapely](https://github.com/shapely/shapely/) and [GeoPandas](https://github.com/geopandas/geopandas), it make use of the [GEOS](https://github.com/libgeos/geos) library, meaning that its API is mostly identical to theirs.\n\n* Documentation: https://oreilles.github.io/polars-st/\n\n```pycon\n\u003e\u003e\u003e import polars_st as st\n\u003e\u003e\u003e gdf = st.GeoDataFrame({\n...     \"category\": [\"A\", \"A\", \"B\"],\n...     \"geometry\": [\n...         \"POLYGON((0 0, 0 4, 4 2, 0 0))\",\n...         \"POLYGON((4 0, 4 4, 0 2, 4 0))\",\n...         \"POLYGON((0 0, 2 2, 2 0, 0 0))\",\n...     ]\n... })\n\u003e\u003e\u003e gdf = gdf.group_by(\"category\").agg(st.intersection_all()).with_columns(area=st.area())\n\u003e\u003e\u003e gdf.st.to_wkt()\nshape: (2, 3)\n┌──────────┬─────────────────────────────────────┬──────┐\n│ category ┆ geometry                            ┆ area │\n│ ---      ┆ ---                                 ┆ ---  │\n│ str      ┆ str                                 ┆ f64  │\n╞══════════╪═════════════════════════════════════╪══════╡\n│ B        ┆ POLYGON ((0 0, 2 2, 2 0, 0 0))      ┆ 2.0  │\n│ A        ┆ POLYGON ((4 2, 2 1, 0 2, 2 3, 4 2)) ┆ 4.0  │\n└──────────┴─────────────────────────────────────┴──────┘\n```\n\n## Installation\n\nPolars ST is published on PyPI so you can install it with your preferred package manager.\n\n```sh\npip install polars-st\n```\n\n## How it works\n\nGeometries are stored as EWKB in regular Polars Binary columns. EWKB is a extension to the WKB standard popularized by PostGIS, that can also store information about the CRS of each geometry as an integer code called SRID.\n\nFor every spatial operations, the WKB binary blob will be parsed into a Geometry object so the operation can be done. If the operation result is a geometry, it will then be serialized back to EWKB. Because of that round-trip, some operations might turn out to be slower than GeoPandas. In most cases however, the performance penalty of that round-trip will be marginal compared to the spatial operation, and you will fully benefit from the parallelization capabilities of Polars.\n\n\n## About GeoPolars\n\n[GeoPolars](https://github.com/geopolars/geopolars) is an very promising tool for manipulating geographic data in Polars based on [GeoArrow](https://github.com/geoarrow/geoarrow) that likely will outperform this library's performance. It however seems to be quite a long way from being ready and feature-complete, mostly due to Polars lack of support for [Arrow Extension Types](https://github.com/pola-rs/polars/issues/9112) and [subclassing of core datatypes](https://github.com/pola-rs/polars/issues/2846#issuecomment-1711799869).\n\n`polars-st` stores geometry as EWKB in regular Binary columns and delegates core functionality to GEOS, which allows it to be ready now, with full support for 3D / 4D coordinates, curved geometry types (CircularString, CurvePolygon, ...) and per-geometry CRS information.\n\n## About Polars\n\nThis project is not affiliated with Polars. The design language was deliberately made very close to that of Polars to highlight the fact that this project is an exclusive extension to Polars, and as a tribute to its effectiveness.\n\n\n## About GEOS\n\nIn order to save myself (and yourself) from the burden of GEOS version-specific features and bugs, `polars-st` statically link to GEOS `main`. This means that all documented features are guaranteed to be available. This also means that this project is LGPL licensed, the same way GEOS is.\n\n## License\n\nCopyright (C) 2024  Aurèle Ferotin\n\nThis library is free software; you can redistribute it and/or\nmodify it under the terms of the GNU Lesser General Public\nLicense as published by the Free Software Foundation; either\nversion 2.1 of the License, or (at your option) any later version.\n\nThis library is distributed in the hope that it will be useful,\nbut WITHOUT ANY WARRANTY; without even the implied warranty of\nMERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU\nLesser General Public License for more details.\n\nYou should have received a copy of the GNU Lesser General Public\nLicense along with this library; if not, write to the Free Software\nFoundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301\nUSA\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foreilles%2Fpolars-st","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Foreilles%2Fpolars-st","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Foreilles%2Fpolars-st/lists"}