Skip to main content

Banner

Polars ST

Polars ST provides spatial operations on Polars DataFrames, Series, and Expressions. Just like Shapely and GeoPandas, it make use of the GEOS library, meaning that its API is mostly identical to theirs.

>>> import polars_st as st
>>> gdf = st.GeoDataFrame({
...     "category": ["A", "A", "B"],
...     "geometry": [
...         "POLYGON((0 0, 0 4, 4 2, 0 0))",
...         "POLYGON((4 0, 4 4, 0 2, 4 0))",
...         "POLYGON((0 0, 2 2, 2 0, 0 0))",
...     ],
... })
>>> gdf = gdf.group_by("category").agg(st.intersection_all()).with_columns(area=st.area())
>>> gdf.with_columns(st.to_wkt())
shape: (2, 3)
┌──────────┬─────────────────────────────────────┬──────┐
│ category ┆ geometry                            ┆ area │
│ ---      ┆ ---                                 ┆ ---  │
│ str      ┆ str                                 ┆ f64  │
╞══════════╪═════════════════════════════════════╪══════╡
│ B        ┆ POLYGON ((0 0, 2 2, 2 0, 0 0))      ┆ 2.0  │
│ A        ┆ POLYGON ((4 2, 2 1, 0 2, 2 3, 4 2)) ┆ 4.0  │
└──────────┴─────────────────────────────────────┴──────┘

Installation

Polars ST is published on PyPI so you can install it with your preferred package manager.

pip install polars-st

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 also stores information about the CRS of each geometry as an integer code called SRID.

For every spatial operations, the WKB 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 WKB. Because of that round-trip, some operations might turn out to be slower than GeoPandas. In most cases however, the performance penalty will be marginal and you will fully benefit from the parallelization capabilities of Polars.

About GeoPolars

GeoPolars is an very promising tool for manipulating geographic data in Polars based on the GeoArrow specification. 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 and subclassing of core datatypes.

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 Z / M coordinates, curved geometry types (CircularString, CurvePolygon, ...) and Series with mixed geometry type and SRIDs.

About Polars

This project is not affiliated with Polars. The design language was deliberately made very close to that of Polars to highlight the fact that this is an exclusive extension to Polars, and as a tribute to the effectiveness of the original design.

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

Metadata

Release files for polars-st 0.10.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for polars-st 0.10.0
File Size Uploaded
polars_st-0.10.0.tar.gz 257.7 kB Details

Built distributions (wheels)

Table of built distributions (wheels) for polars-st 0.10.0
File
polars_st-0.10.0-cp310-abi3-win_arm64.whl CPython 3.10 abi3 Windows ARM64 Details
polars_st-0.10.0-cp310-abi3-win_amd64.whl CPython 3.10 abi3 Windows x86-64 Details
polars_st-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl CPython 3.10 abi3 Linux glibc 2.17+ x86-64 Details
polars_st-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl CPython 3.10 abi3 Linux glibc 2.17+ ARM64 Details
polars_st-0.10.0-cp310-abi3-macosx_11_0_arm64.whl CPython 3.10 abi3 macOS 11.0+ ARM64 Details
polars_st-0.10.0-cp310-abi3-macosx_10_12_x86_64.whl CPython 3.10 abi3 macOS 10.12+ x86-64 Details

Total release size: 320.8 MB

Release files / polars_st-0.10.0.tar.gz

Download URL polars_st-0.10.0.tar.gz
Size 257.7 kB
Tags Source
SHA-256 checksum
How to use checksums
bc41888ca3544364259ed6955500654a0e81a7e247fc70393c0c42c54dd2820f
BLAKE2b-256 checksum
How to use checksums
18ca51be25a485413e9c0c56da37018e36b736004b52cdc98534e8d3bcd5629a
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-win_arm64.whl

Download URL polars_st-0.10.0-cp310-abi3-win_arm64.whl
Size 49.4 MB
Tags CPython 3.10 Windows ARM64 abi3
SHA-256 checksum
How to use checksums
cb78156a1496a9ab45b0d7dcd1a70df36958d33090930f3d5f67cfb2bea775f7
BLAKE2b-256 checksum
How to use checksums
6b82ef2a973d9c5a6ec839523d5f8ca4b4830c8cc30614ccc5052a3e7f529fe8
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-win_amd64.whl

Download URL polars_st-0.10.0-cp310-abi3-win_amd64.whl
Size 54.8 MB
Tags CPython 3.10 Windows x86-64 abi3
SHA-256 checksum
How to use checksums
9de7e2fec100c46158cb4491cf7c68693a905437ca4a3ac3fd257f4a3566dfde
BLAKE2b-256 checksum
How to use checksums
4bf98f092f9f4443b9d92d3ae57202097e7fd391d3a778cb19d6e7e8ca37c9fc
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl

Download URL polars_st-0.10.0-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Size 51.9 MB
Tags CPython 3.10 Linux glibc 2.17+ x86-64 abi3
SHA-256 checksum
How to use checksums
d6238ef734b0576f47f91f0c7e2be086785246a0b07f1736a554305166e437a0
BLAKE2b-256 checksum
How to use checksums
a9f6043ffad47a7a8079bd9b6ee3babc8aeceef29f5ea084f2f79189b84ab684
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl

Download URL polars_st-0.10.0-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Size 48.3 MB
Tags CPython 3.10 Linux glibc 2.17+ ARM64 abi3
SHA-256 checksum
How to use checksums
57cdddbc940104c3c1eef5bd923e237746f08ca4f4851848911edcaab8f2362e
BLAKE2b-256 checksum
How to use checksums
e642171605246e511c8d5cc685df5dd62752098b7beced3ced411bcd2c3916ed
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-macosx_11_0_arm64.whl

Download URL polars_st-0.10.0-cp310-abi3-macosx_11_0_arm64.whl
Size 57.2 MB
Tags CPython 3.10 abi3 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
a8f2ae99585dae0d07c6fbeab0a62046c54550bffaad8e46780c128272c1f07c
BLAKE2b-256 checksum
How to use checksums
7428c794475dc19b1fecb203a7d7df526db37cbdce3e21ea194de5b640a60e7f
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release files / polars_st-0.10.0-cp310-abi3-macosx_10_12_x86_64.whl

Download URL polars_st-0.10.0-cp310-abi3-macosx_10_12_x86_64.whl
Size 59.0 MB
Tags CPython 3.10 abi3 macOS 10.12+ x86-64
SHA-256 checksum
How to use checksums
030c75679a47b329e93ae1e4a69ff8bf82dc1af9d3fc79109d4d99d27e41c7bd
BLAKE2b-256 checksum
How to use checksums
f5d18f478e808a9afb15985dd086e9a1dc8a788996bd4dd7c74ae8f713084060
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via maturin/1.15.0

Release history Release notifications | RSS feed

This release

0.10.0 This release

7 release files

0.9.0

7 release files

0.8.0

7 release files

0.7.2

7 release files

0.7.1

7 release files

0.7.0

7 release files

0.6.2

7 release files

0.6.1

6 release files

0.6.0

6 release files

0.5.0

6 release files

0.4.3

6 release files

0.4.2

6 release files

0.4.1

6 release files

0.4.0

6 release files

0.3.0

6 release files

0.2.0

6 release files

0.1.9

6 release files

0.1.8

6 release files

0.1.7

6 release files

0.1.6

6 release files

0.1.5

6 release files

0.1.4

6 release files

0.1.3

6 release files

0.1.2

6 release files

0.1.1

6 release files

0.1.0

6 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page