Skip to content
프로젝트

소개

Polars용 지리 공간 확장 기능입니다.

과학 및 공학

이 수치를 측정하는 방법

측정된 스타 증가

in 24h
+1
in 7 days
+3
in 15 days
+7
in 1 month
기록 수집 중

서로 겹치는 기간의 순증가량이며 일별 합계가 아닙니다. 측정값이 없으면 비워 둡니다. 스타는 관심도를 나타내며 품질을 보장하지 않습니다.

README.md

Original

GeoPolars logo

Documentation: Python | User guide

GeoPolars: geospatial data types and operations for Polars

GeoPolars adds first-class geospatial data types to Polars. On top of being compatible with many existing Polars functionality, these data types also come with a suite of geo-specific expressions. They are regular Polars expressions, so they work in lazy queries and the streaming engine like any other.

  • Native geometry types: points, line strings, polygons and their multi forms, in 2D, with z and with m, stored as GeoArrow.
  • Checked at plan time: a mismatched type or an unsupported operation is refused while the query is built, not halfway through running it.
  • CRS-aware: every geometry column carries its CRS. Reprojection is backed by PROJ, and area and distance are measured on their ellipsoid for longitude/latitude.
  • GeoParquet: read and write it with Polars' own Parquet readers and writers.

To learn more, read the user guide.

GeoPolars in action

Reading GeoParquet

GeoParquet keeps the encoding and the CRS of its geometry columns in the metadata of the file, which Polars reads when POLARS_GEOPARQUET_READ is set. The CRS here is longitude/latitude, so area measures on the ellipsoid, in square metres:

import os

import polars as pl

import geopolars as gpl
from geopolars import MultiPolygonXY, geo

# Polars' GeoParquet support is still experimental, and must be switched on.
os.environ["POLARS_GEOPARQUET_READ"] = "1"

countries = (
    pl.scan_parquet("countries.parquet")
    .select("name", geometry=geo.from_wkb("geometry", MultiPolygonXY))
    .with_columns(area_km2=geo.area("geometry") / 1e6)
    .sort("area_km2", descending=True)
    .collect()
)

From longitude/latitude to GeoParquet

Build points from plain coordinate columns, reproject them, and write a file that other GeoParquet readers (such as GeoPandas and GDAL) understand. POLARS_GEOPARQUET_WRITE makes Polars write the metadata they need:

os.environ["POLARS_GEOPARQUET_WRITE"] = "1.1"

cities = pl.scan_csv("cities.csv").select(
    "city",
    # EPSG:28992 is the Dutch national grid, in metres.
    geometry=geo.to_crs(geo.point("lon", "lat", crs="EPSG:4326"), "EPSG:28992"),
)
# GeoParquet needs the CRS as PROJJSON, rather than as a code.
cities.with_columns(geo.crs_to_projjson("geometry")).sink_parquet("cities.parquet")

Every operation is also in the .geo namespace: gpl.col("geometry").geo.area() is the same as geo.area("geometry").

Installation

Install the latest GeoPolars version with:

pip install geopolars

GeoPolars is in alpha: expect breaking changes between releases. See installation in the user guide for what it requires and comes with.

Compile GeoPolars from source

GeoPolars builds against a pinned commit of Polars, which make install checks out into .polars and builds as well.

  1. Install the latest Rust compiler and uv.
  2. Install what the bundled PROJ and GEOS are built with:
    • a C++ compiler and CMake, for both.
    • SQLite, both the library and the sqlite3 binary, for PROJ only. On Debian or Ubuntu: sudo apt-get install build-essential cmake sqlite3 libsqlite3-dev.
  3. From the root of the repository, choose one of the following:
    • make install, an unoptimised build, with fast compile times.
    • make install-release, an optimised build, with long compile times.

Both set up a virtual environment in .venv with GeoPolars installed. Run make help to see the other targets.

Contributing

Want to contribute? Read our contributing guide and check the issue tracker.

License

GeoPolars is licensed under the MIT License (SPDX: MIT).

관련 프로젝트 살펴보기

불러오는 중…