pola-rs / polars

Dataframes powered by a multithreaded, vectorized query engine, written in Rust
https://docs.pola.rs
Other
30.66k stars 1.99k forks source link

Add support for vector (gdal) geometries #3208

Closed geohardtke closed 2 years ago

geohardtke commented 2 years ago

Hi there, Would be nice to have the ability to create Series of Geometry types, and then build functionality similar to geopandas (which I miss in rust) like opening a geopackage or shape file as a DataFrame.

For example:

use gdal::{vector};
use polars::series::Series;
use polars::prelude::NamedFrom;

fn main() {
    let mut geoms: Vec<vector::Geometry> = Vec::new();
    let mut geoms = vector::Geometry::empty(vector::OGRwkbGeometryType::wkbPoint).unwrap();
    geoms.add_point((0., 0., 0.));
    geoms.add_point((0., 1.,1.));
    let s = Series::new("geometry", geoms);
}

which of course returns:

  --> src/main.rs:10:17
   |
10 |         let s = Series::new("geometry", geoms);
   |                 ^^^^^^^^^^^ the trait `NamedFrom<Geometry, _>` is not implemented for `Series`
   |

If there is some interest in having this functionality added, I'm willing to (with a bit of help) try to implement it.

Cheers

program-- commented 2 years ago

To add to this, it should be easier to add support for this once the GeoArrow format specification is stable (and similarly, OGC's GeoParquet specification. Both will inherently add GDAL support). This would be great to have!

nmandery commented 2 years ago

There also has been some related previous discussion in #1830

kylebarron commented 2 years ago

Should we close this to keep discussion in #1830?

zundertj commented 2 years ago

Closing; the discussion can continue in #1830.

phayes commented 1 year ago

@geohardtke , I've implemented a GDAL <-> Polars connector cate: https://github.com/phayes/polars_gdal

geohardtke commented 1 year ago

brilliant work! I'll check it out @phayes