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

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

polars_st-0.7.1.tar.gz (256.7 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

polars_st-0.7.1-cp310-abi3-win_arm64.whl (46.7 MB view details)

Uploaded CPython 3.10+Windows ARM64

polars_st-0.7.1-cp310-abi3-win_amd64.whl (54.0 MB view details)

Uploaded CPython 3.10+Windows x86-64

polars_st-0.7.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl (50.4 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ x86-64

polars_st-0.7.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl (45.5 MB view details)

Uploaded CPython 3.10+manylinux: glibc 2.17+ ARM64

polars_st-0.7.1-cp310-abi3-macosx_11_0_arm64.whl (53.9 MB view details)

Uploaded CPython 3.10+macOS 11.0+ ARM64

polars_st-0.7.1-cp310-abi3-macosx_10_12_x86_64.whl (57.1 MB view details)

Uploaded CPython 3.10+macOS 10.12+ x86-64

File details

Details for the file polars_st-0.7.1.tar.gz.

File metadata

  • Download URL: polars_st-0.7.1.tar.gz
  • Upload date:
  • Size: 256.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for polars_st-0.7.1.tar.gz
Algorithm Hash digest
SHA256 6a322ddfedfa54da56608bad1c3619163619ffd89a6a2053c811b1b3659897cb
MD5 ec9d82715f05a07531ca5f794a24d1dc
BLAKE2b-256 0d84580ad89e663a608926c7ef2b44bce2bba89c9c20de8fd99708ecc2737fdc

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-win_arm64.whl.

File metadata

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-win_arm64.whl
Algorithm Hash digest
SHA256 74e545dfd34f3febdb3e377f214836c9782e673f174659d841a81c14e4e2ceb8
MD5 01d96a29850a49df1728861aeb562f95
BLAKE2b-256 e79af1d60e6beda8148dab6a6f14f96057855689b165318f187182bd0eef2c3a

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-win_amd64.whl.

File metadata

  • Download URL: polars_st-0.7.1-cp310-abi3-win_amd64.whl
  • Upload date:
  • Size: 54.0 MB
  • Tags: CPython 3.10+, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: maturin/1.14.1

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 18df9351131fc2750c5c43f5aa73ab7dc28fa4293dfd22ff98ce39c8f7017df5
MD5 c41fceefcfc66588cec502a8485ac602
BLAKE2b-256 19850f9b05e08cf42e3ff51f97dd03969cdba4d819c636fc515fb8b04d6d8e4d

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl.

File metadata

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-manylinux_2_17_x86_64.manylinux2014_x86_64.whl
Algorithm Hash digest
SHA256 3d3bc6a0e5e14181f0fc333d2595a5fbafec996dc002e92760fa2b22e2a5559a
MD5 ed626ad29756ae20cda6d0956fb15ad4
BLAKE2b-256 a0fb111ddb875d48e820542942d52df8a36e045167a074dfed4bd4420814e5bd

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl.

File metadata

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-manylinux_2_17_aarch64.manylinux2014_aarch64.whl
Algorithm Hash digest
SHA256 759834396f74582cbe68707845e93928cf5baf843469655a1818eaf36cd53d08
MD5 7a08c70724fc0d83564dae7784e1b8f1
BLAKE2b-256 b636384c57c32a9d250b670cbeef7be627329cb42cb0e19de1fb1b23e3afc919

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 78ce521326d11eb6669968a2587138c3171bd0b03c8a772d4ab686407c68cc6c
MD5 300ff1c073df74c12f1d0c578aa34eb0
BLAKE2b-256 662536b8ee8a1daa428afa264eb5798ba99ef5ae74d20f92a0504468ae7f3f3b

See more details on using hashes here.

File details

Details for the file polars_st-0.7.1-cp310-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for polars_st-0.7.1-cp310-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 06b818e810d79317913366b0d7cc6838ee91541954528bce44ccad9257a19860
MD5 7738d8f22426f52d59528d19c033c2e5
BLAKE2b-256 da04b270f62bdcaefe21ab34dc8ffb3adc52f1df2678f9aa06f13d694b93bbbd

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.7.1 This release

7 files

0.7.0

7 files

0.6.2

7 files

0.6.1

6 files

0.6.0

6 files

0.5.0

6 files

0.4.3

6 files

0.4.2

6 files

0.4.1

6 files

0.4.0

6 files

0.3.0

6 files

0.2.0

6 files

0.1.9

6 files

0.1.8

6 files

0.1.7

6 files

0.1.6

6 files

0.1.5

6 files

0.1.4

6 files

0.1.3

6 files

0.1.2

6 files

0.1.1

6 files

0.1.0

6 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