polars-st


Namepolars-st JSON
Version 0.1.0a9 PyPI version JSON
download
home_pageNone
SummarySpatial extension for Polars DataFrames
upload_time2024-09-25 12:47:38
maintainerNone
docs_urlNone
authorNone
requires_python>=3.10
licenseLGPL-2.1
keywords polars dataframe gis geospatial geometry
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            [![Banner](https://raw.githubusercontent.com/Oreilles/polars-st/main/assets/banner.svg)](#)

# Polars ST

Polars 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 library [GEOS](https://github.com/libgeos/geos), meaning that its API is mostly identical to theirs.

```pycon
>>> import polars as pl
>>> import polars_st as st
>>> gdf = st.GeoDataFrame([
...     "POINT (0 0)",
...     "LINESTRING (0 0, 1 1, 2 2)",
...     "POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))",
... ])
>>> gdf.select(st.centroid().st.to_geojson())
┌──────────────────────────────────────────┐
│ geometry                                 │
│ ---                                      │
│ str                                      │
╞══════════════════════════════════════════╡
│ {"type":"Point","coordinates":[0.0,0.0]} │
│ {"type":"Point","coordinates":[1.0,1.0]} │
│ {"type":"Point","coordinates":[0.5,0.5]} │
└──────────────────────────────────────────┘
```

## How it works

Geometries 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.

For 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.


## About GeoPolars

[GeoPolars](https://github.com/geopolars/geopolars) is an incredibly promising tool for manipulating geographic data in Polars based on [GeoArrow](https://github.com/geoarrow/geoarrow) that likely will outperform this library's performance by a long shot. 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).

Storing geometry as EWKB and delegating core functionality to GEOS allows `polars-st` to be ready now, and provide additional features such as XYZM coordinates, curved geometry types and per-geometry CRS information.

I really hope Geopolars get there soon, and that maybe some of the API design explorations made here will have helped make it even more pleasant to use.

## About Polars

This project is not affiliated with Polars. The design language was made very close to that of Polars because I found it amazingly appealing and liked the challenge of adding geographic meaning to it, and to also hilight the fact that this project is an exclusive extension to Polars.


## About GEOS

In 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.

## License

Copyright (C) 2024  Aurèle Ferotin

This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.

This library is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
Lesser General Public License for more details.

You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301
USA


            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "polars-st",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.10",
    "maintainer_email": null,
    "keywords": "polars, dataframe, gis, geospatial, geometry",
    "author": null,
    "author_email": null,
    "download_url": "https://files.pythonhosted.org/packages/0f/c6/64f93a63eacda25d98f99d19cc8b90e318d7ddcedca1af4e361992bfef44/polars_st-0.1.0a9.tar.gz",
    "platform": null,
    "description": "[![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 library [GEOS](https://github.com/libgeos/geos), meaning that its API is mostly identical to theirs.\n\n```pycon\n>>> import polars as pl\n>>> import polars_st as st\n>>> gdf = st.GeoDataFrame([\n...     \"POINT (0 0)\",\n...     \"LINESTRING (0 0, 1 1, 2 2)\",\n...     \"POLYGON ((0 0, 1 0, 1 1, 0 1, 0 0))\",\n... ])\n>>> gdf.select(st.centroid().st.to_geojson())\n\u250c\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2510\n\u2502 geometry                                 \u2502\n\u2502 ---                                      \u2502\n\u2502 str                                      \u2502\n\u255e\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2550\u2561\n\u2502 {\"type\":\"Point\",\"coordinates\":[0.0,0.0]} \u2502\n\u2502 {\"type\":\"Point\",\"coordinates\":[1.0,1.0]} \u2502\n\u2502 {\"type\":\"Point\",\"coordinates\":[0.5,0.5]} \u2502\n\u2514\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2518\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 incredibly promising tool for manipulating geographic data in Polars based on [GeoArrow](https://github.com/geoarrow/geoarrow) that likely will outperform this library's performance by a long shot. 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\nStoring geometry as EWKB and delegating core functionality to GEOS allows `polars-st` to be ready now, and provide additional features such as XYZM coordinates, curved geometry types and per-geometry CRS information.\n\nI really hope Geopolars get there soon, and that maybe some of the API design explorations made here will have helped make it even more pleasant to use.\n\n## About Polars\n\nThis project is not affiliated with Polars. The design language was made very close to that of Polars because I found it amazingly appealing and liked the challenge of adding geographic meaning to it, and to also hilight the fact that this project is an exclusive extension to Polars.\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\u00e8le 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\n",
    "bugtrack_url": null,
    "license": "LGPL-2.1",
    "summary": "Spatial extension for Polars DataFrames",
    "version": "0.1.0a9",
    "project_urls": {
        "Source Code": "https://github.com/Oreilles/polars-st"
    },
    "split_keywords": [
        "polars",
        " dataframe",
        " gis",
        " geospatial",
        " geometry"
    ],
    "urls": [
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "e00140bdd69282418442436c3d2326a9cdbfae32792b6044791f064e6bff91de",
                "md5": "d7fc0bdf342a8108f74663fe5cadde7d",
                "sha256": "72da420f6389fe11fa5101e05ae743fdc13bc0900caa78db52d0238658f0ad77"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-macosx_10_12_x86_64.whl",
            "has_sig": false,
            "md5_digest": "d7fc0bdf342a8108f74663fe5cadde7d",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 11337649,
            "upload_time": "2024-09-25T12:47:22",
            "upload_time_iso_8601": "2024-09-25T12:47:22.652925Z",
            "url": "https://files.pythonhosted.org/packages/e0/01/40bdd69282418442436c3d2326a9cdbfae32792b6044791f064e6bff91de/polars_st-0.1.0a9-cp38-abi3-macosx_10_12_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5a466b199d1d5eb2fd19948986c4a4f5eb75d48b7c5e49ea0de63b327fb0bfe5",
                "md5": "0d7670a7346414c15a88e8732742d7cc",
                "sha256": "6a70905101a43565bbe99e34daa97a594343ac1eb8ef4aadf8fb86c53a621bdd"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-macosx_11_0_arm64.whl",
            "has_sig": false,
            "md5_digest": "0d7670a7346414c15a88e8732742d7cc",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 10646571,
            "upload_time": "2024-09-25T12:47:19",
            "upload_time_iso_8601": "2024-09-25T12:47:19.592141Z",
            "url": "https://files.pythonhosted.org/packages/5a/46/6b199d1d5eb2fd19948986c4a4f5eb75d48b7c5e49ea0de63b327fb0bfe5/polars_st-0.1.0a9-cp38-abi3-macosx_11_0_arm64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f0ea247f02ec3b9874dab0c6077166d4c22f5d0dd3f157ade5f72d0bf363419d",
                "md5": "f6303d98fe9997d31dcce218c79121fe",
                "sha256": "c289caed891c24f27f63514d70f6929cbf3cf07a065bb66d72269dfc8ae0ac4e"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "has_sig": false,
            "md5_digest": "f6303d98fe9997d31dcce218c79121fe",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 9609661,
            "upload_time": "2024-09-25T12:47:06",
            "upload_time_iso_8601": "2024-09-25T12:47:06.995709Z",
            "url": "https://files.pythonhosted.org/packages/f0/ea/247f02ec3b9874dab0c6077166d4c22f5d0dd3f157ade5f72d0bf363419d/polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "328a74f7222a61f08e5c8cd5bbdbd73eec679eec68d660fecd93814348299aab",
                "md5": "764ef88b85588455424d5609db039029",
                "sha256": "22b155fb3cd0ebb65b552146a894fdb050cb389ec134148d7aa4c077959076be"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "has_sig": false,
            "md5_digest": "764ef88b85588455424d5609db039029",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 9547690,
            "upload_time": "2024-09-25T12:47:10",
            "upload_time_iso_8601": "2024-09-25T12:47:10.348220Z",
            "url": "https://files.pythonhosted.org/packages/32/8a/74f7222a61f08e5c8cd5bbdbd73eec679eec68d660fecd93814348299aab/polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_armv7l.manylinux2014_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "5325022bb819cd9ddee097a4a47d06efb47dbb626301f63bdce7cd6abd3cbc39",
                "md5": "d67d2ced1a32228c28f1dd32d85b38d3",
                "sha256": "610d6cceab8812c7716d0aecd8f79d32f4a96eecf7ae50e24d1a96b431f4c598"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl",
            "has_sig": false,
            "md5_digest": "d67d2ced1a32228c28f1dd32d85b38d3",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 11508410,
            "upload_time": "2024-09-25T12:47:13",
            "upload_time_iso_8601": "2024-09-25T12:47:13.238208Z",
            "url": "https://files.pythonhosted.org/packages/53/25/022bb819cd9ddee097a4a47d06efb47dbb626301f63bdce7cd6abd3cbc39/polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_i686.manylinux2014_i686.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "b7388605b61b5aaf8d3d94b310156cfafd65f91cf801d9bf48d7827cd3dc6f14",
                "md5": "5559cf3d12bbbad851d146e12316e0c1",
                "sha256": "d76f9d42d91a1735112dbe4b6292786703b942736489ce81d819d349b34e7d75"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "has_sig": false,
            "md5_digest": "5559cf3d12bbbad851d146e12316e0c1",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 10572247,
            "upload_time": "2024-09-25T12:47:16",
            "upload_time_iso_8601": "2024-09-25T12:47:16.687611Z",
            "url": "https://files.pythonhosted.org/packages/b7/38/8605b61b5aaf8d3d94b310156cfafd65f91cf801d9bf48d7827cd3dc6f14/polars_st-0.1.0a9-cp38-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "31931c8dd4947a0eedf9a144930c42013272ce890ed586324fd9d86b34d4d534",
                "md5": "994c2fd93c1632b53093677c5ffc1b9c",
                "sha256": "95f109bb213995466a8f25c2b1d8e0ecd4c2aceab7fe3aaf013cd4c60c2fc286"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_aarch64.whl",
            "has_sig": false,
            "md5_digest": "994c2fd93c1632b53093677c5ffc1b9c",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 9427673,
            "upload_time": "2024-09-25T12:47:25",
            "upload_time_iso_8601": "2024-09-25T12:47:25.447966Z",
            "url": "https://files.pythonhosted.org/packages/31/93/1c8dd4947a0eedf9a144930c42013272ce890ed586324fd9d86b34d4d534/polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_aarch64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "f112a19018facbffc6fca40821c96c7b701de9e4b16ab9b14830517410a3fb48",
                "md5": "017ec66a4c501480712cbb19576bf499",
                "sha256": "aa4e86ca9af250bbd0680a31a6fc72e7d39673718f40ac2e07de6a713ac0e7a2"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_armv7l.whl",
            "has_sig": false,
            "md5_digest": "017ec66a4c501480712cbb19576bf499",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 9532823,
            "upload_time": "2024-09-25T12:47:28",
            "upload_time_iso_8601": "2024-09-25T12:47:28.396517Z",
            "url": "https://files.pythonhosted.org/packages/f1/12/a19018facbffc6fca40821c96c7b701de9e4b16ab9b14830517410a3fb48/polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_armv7l.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "8b5846a6777fc3ae79f422b623a7c274fd047512e65ba6359f182e5b3c05848b",
                "md5": "f61a425c60c4f2e53846305e6f43e923",
                "sha256": "940a1c0e5ee0bf09c7a32b2a94a7b22886b598c8b2d91167cd3c37100e518922"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_i686.whl",
            "has_sig": false,
            "md5_digest": "f61a425c60c4f2e53846305e6f43e923",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 10980099,
            "upload_time": "2024-09-25T12:47:31",
            "upload_time_iso_8601": "2024-09-25T12:47:31.695927Z",
            "url": "https://files.pythonhosted.org/packages/8b/58/46a6777fc3ae79f422b623a7c274fd047512e65ba6359f182e5b3c05848b/polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_i686.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "4c8a343bd2d7da54479a29fa48b6cfc1f3e2eca2b1dc11e0c997df82480989a8",
                "md5": "de219e380512052f55f36ee8d552d438",
                "sha256": "4c96b00afc6c4d56b6c88ece9d50c5bfbc0d10d3c18f2864b09097266a354abd"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_x86_64.whl",
            "has_sig": false,
            "md5_digest": "de219e380512052f55f36ee8d552d438",
            "packagetype": "bdist_wheel",
            "python_version": "cp38",
            "requires_python": ">=3.10",
            "size": 10569163,
            "upload_time": "2024-09-25T12:47:35",
            "upload_time_iso_8601": "2024-09-25T12:47:35.571213Z",
            "url": "https://files.pythonhosted.org/packages/4c/8a/343bd2d7da54479a29fa48b6cfc1f3e2eca2b1dc11e0c997df82480989a8/polars_st-0.1.0a9-cp38-abi3-musllinux_1_2_x86_64.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": null,
            "digests": {
                "blake2b_256": "0fc664f93a63eacda25d98f99d19cc8b90e318d7ddcedca1af4e361992bfef44",
                "md5": "74ee5d42d2f1416c1cd425b005485ba5",
                "sha256": "36b359443ee73cbf2864557959b562dcd771ed59b609109b16994e6c7377b380"
            },
            "downloads": -1,
            "filename": "polars_st-0.1.0a9.tar.gz",
            "has_sig": false,
            "md5_digest": "74ee5d42d2f1416c1cd425b005485ba5",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.10",
            "size": 162091,
            "upload_time": "2024-09-25T12:47:38",
            "upload_time_iso_8601": "2024-09-25T12:47:38.148739Z",
            "url": "https://files.pythonhosted.org/packages/0f/c6/64f93a63eacda25d98f99d19cc8b90e318d7ddcedca1af4e361992bfef44/polars_st-0.1.0a9.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-25 12:47:38",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "Oreilles",
    "github_project": "polars-st",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "polars-st"
}
        
Elapsed time: 2.73857s