Read GDAL compatible file formats into polars / geopolars

Overview

Read GDAL-compatible geospatial data into Polars and GeoPolars.

Supports reading the following geospatial formats into a Polars Dataframe:

  1. GeoJSON
  2. ShapeFiles
  3. CSV with lat / lon
  4. FlatGeobuf
  5. KML
  6. GPX
  7. PostGIS (via network)
  8. SpatialLite
  9. ... and many more

Example 1: Dataframe from a file

use geopolars_gdal::df_from_resource;
let df = df_from_resource("my_shapefile.shp", None).unwrap();
println!("{}", df);

Example 2: DataFrame from raw bytes

use geopolars_gdal::df_from_bytes;

let geojson = r#"{"type":"FeatureCollection","features":[{"type":"Feature","properties":{"name":"foo"},"geometry":{"type":"Point","coordinates":[1,2]}},{"type":"Feature","properties":{"name":"bar"},"geometry":{"type":"Point","coordinates":[3,4]}}]}"#.as_bytes().to_vec();

let df = df_from_bytes(geojson, None, None).unwrap();
println!("{}", df);

Example 3: Dataframe from GDAL Layer with filtering query

use geopolars_gdal::{df_from_layer, gdal};
use gdal::vector::sql;

let dataset = gdal::Dataset::open("my_shapefile.shp")?;
let query = "SELECT kind, is_bridge, highway FROM my_shapefile WHERE highway = 'pedestrian'";
let mut result_set = dataset.execute_sql(query, None, sql::Dialect::DEFAULT).unwrap().unwrap();

let df = df_from_layer(&mut result_set, None).unwrap();
println!("{}", df);

Example 4: Dataframe from Latitude / Longitude CSV with custom parsing options

let mut params = geopolars_gdal::Params::default();
let csv_parsing_options = ["EMPTY_STRING_AS_NULL=YES", "KEEP_GEOM_COLUMNS=NO", "X_POSSIBLE_NAMES=Lon*", "Y_POSSIBLE_NAMES=Lat*"];
params.open_options = Some(&csv_parsing_options);
 
let df = df_from_resource("lat_lon_countries.csv", Some(params)).unwrap();
println!("{}", df);

Example 5: Dataframe from a PostGIS table

use geopolars_gdal::{df_from_resource, Params};

let mut params = Params::default();
params.layer_name = Some("some_table_name");
 
let df = df_from_resource("postgresql://user:pass@host/db_name", Some(params)).unwrap();
println!("{}", df);
You might also like...
Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

Polars is a blazingly fast DataFrames library implemented in Rust using Apache Arrow Columnar Format as memory model.
Polars is a blazingly fast DataFrames library implemented in Rust using Apache Arrow Columnar Format as memory model.

Polars Python Documentation | Rust Documentation | User Guide | Discord | StackOverflow Blazingly fast DataFrames in Rust, Python & Node.js Polars is

A dataframe manipulation tool inspired by dplyr and powered by polars.

dply is a command line tool for viewing, querying, and writing csv and parquet files, inspired by dplyr and powered by polars. Usage overview A dply p

Work with bioinformatic files using Arrow, Polars, and/or DuckDB

biobear is a Python library designed for reading and searching bioinformatic file formats, using Rust as its backend and producing Arrow Batch Readers

Reddit - Liberate your Reddit Chats. This tool will export your reddit chats into a plethora of formats

Rexit Rexit - Liberate your Reddit Chats. This tool will export your Reddit chats into a plethora of formats Tool to export Reddit chats into a variet

Generate and translate standard uuids into shorter formats and back.

short-uuid Generate and translate standard UUIDs into shorter or just different formats and back. A port of the JavaScript npm package short-uuid so b

This crate converts Rust compatible regex-syntax to Vim's NFA engine compatible regex.

This crate converts Rust compatible regex-syntax to Vim's NFA engine compatible regex.

A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji
A simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art version constructed with emoji

EmojiPix This is a simple command-line utility (and Rust crate!) for converting from a conventional image file (e.g. a PNG file) into a pixel-art vers

🖼️Combines a Javascript and WASM file into a single executable polygot PNG+HTML file.

WASIMAGE Combines a Javascript and WASM file into a single executable polygot PNG+HTML file. Usage: cargo install wasimage wasimage --wasm-file my.was

FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension
FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension

FileSorterX is an automatic file sorting application that sorts your files into folders based on their file extension. With FileSorterX, you can easily keep your files organized and find what you need quickly.

Tool written in rust to read for file changes and accordingly run build commands.

Sniff A simple tool written in rust to read for file changes and accordingly run build commands. Note this tool is for linux and linux only. If it hap

A PoC for the CVE-2022-44268 - ImageMagick arbitrary file read
A PoC for the CVE-2022-44268 - ImageMagick arbitrary file read

CVE-2022-44268 Arbitrary File Read PoC - PNG generator This is a proof of concept of the ImageMagick bug discovered by https://www.metabaseq.com/image

Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.
Tight Model format is a lossy 3D model format focused on reducing file size as much as posible without decreasing visual quality of the viewed model or read speeds.

What is Tight Model Format The main goal of the tmf project is to provide a way to save 3D game assets compressed in such a way, that there are no not

Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're working with files or directories, this tool simplifies common file operations with ease.

Rust FileOps Rust File Management CLI is a command-line tool written in Rust that provides essential file management functionalities. Whether you're w

Unpack a CircleCI orb.yml into separate files compatible with orb packing

CircleCI Orb Unpacking Tool This CLI tool is designed to facilitate the process of migrating a CircleCI Orb to the Orb Development Kit format, where c

Unpack a CircleCI orb.yml into separate files compatible with orb packing

CircleCI Orb Unpacking Tool This CLI tool is designed to facilitate the process of migrating a CircleCI Orb to the Orb Development Kit format, where c

Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes
Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes

What is Lust? Lust is a static image server designed to automatically convert uploaded image to several formats and preset sizes with scaling in mind.

archive-rs provides a generic way of dealing with multiple archive and compression formats in Rust

archive-rs A Rust crate that aims to provide a generic way of dealing with multiple archive and compression formats by providing a generic abstraction

Prometheus exporter that scrapes data in different formats

data-exporter A prometheus exporter that scrapes remote data or local files and converts them to prometheus metrics. It is similar to json_exporter, b

Owner
Patrick Hayes
Secure Code, Cryptography, Voting
Patrick Hayes
Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

GeoRust 208 Dec 27, 2022
Rust read/write support for well-known text (WKT)

wkt Rust read/write support for well-known text (WKT). License Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE or http://www.apac

GeoRust 40 Dec 11, 2022
Rust read/write support for GPS Exchange Format (GPX)

gpx gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS

GeoRust 63 Dec 5, 2022
Rust read/write support for GPS Exchange Format (GPX)

gpx gpx is a library for reading and writing GPX (GPS Exchange Format) files. It uses the primitives provided by geo-types to allow for storage of GPS

GeoRust 63 Dec 5, 2022
Rust read/write support for well-known text (WKT)

wkt Rust read/write support for well-known text (WKT). License Licensed under either of Apache License, Version 2.0 (LICENSE-APACHE or http://www.apac

GeoRust 40 Dec 11, 2022
Crate for slicing GeoJSON into vector tiles on the fly.

geojson-vt-rs — GeoJSON Vector Tiles Port to Rust of C++ GeoJSON-VT for slicing GeoJSON into vector tiles on the fly. A highly efficient Rust library

Max Ammann 19 Sep 15, 2024
Library for serializing the GeoJSON vector GIS file format

geojson Documentation Library for serializing the GeoJSON vector GIS file format Minimum Rust Version This library requires a minimum Rust version of

GeoRust 176 Dec 27, 2022
Library for serializing the GeoJSON vector GIS file format

geojson Documentation Library for serializing the GeoJSON vector GIS file format Minimum Rust Version This library requires a minimum Rust version of

GeoRust 176 Dec 27, 2022
Read specialized NGS formats as data frames in R, Python, and more.

oxbow Read specialized bioinformatic file formats as data frames in R, Python, and more. File formats create a lot of friction for computational biolo

null 12 Jun 7, 2023
Rust bindings for GDAL

gdal [] GDAL bindings for Rust. So far, you can: open a raster dataset for reading/writing get size and number of bands get/set projection and geo-tra

GeoRust 211 Jan 4, 2023