Read and write GDAL-compatible geospatial data into Polars and GeoPolars.

Supports reading and writing the following geospatial formats into / from 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

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

Example 2: DataFrame from raw bytes

```rust # ignore use polarsgdal::dffrom_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();

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

Example 3: DataFrame from GDAL Layer with filtering query

```rust # ignore use polarsgdal::{dffrom_layer, gdal}; use gdal::vector::sql;

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

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

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

```rust # ignore let mut params = polarsgdal::Params::default(); let csvparsingoptions = ["EMPTYSTRINGASNULL=YES", "KEEPGEOMCOLUMNS=NO", "XPOSSIBLENAMES=Lon", "Y_POSSIBLE_NAMES=Lat"]; params.openoptions = Some(&csvparsing_options);

let df = dffromresource("latloncountries.csv", Some(params)).unwrap(); println!("{}", df); ```

Example 5: DataFrame from a PostGIS table

```rust # ignore use polarsgdal::{dffrom_resource, Params};

let mut params = Params::default(); params.layername = Some("sometable_name");

let df = dffromresource("postgresql://user:pass@host/db_name", Some(params)).unwrap(); println!("{}", df); ```

Example 6: GeoJSON bytes from a Dataframe

```rust # ignore use polarsgdal::{gdal, gdalbytesfromdf, WriteParams};

let df: DataFrame = ...; let jsondriver = gdal::DriverManager::getdriverbyname("GeoJSON")?; let geojsonbytes = gdalbytesfromdf(&df, &json_driver, None)?; ```

Example 7: Write a shapefile to disk from a DataFrame

```rust # ignore use polarsgdal::{gdal, gdalresourcefromdf, WriteParams};

let df: DataFrame = ...; let shapefiledriver = gdal::DriverManager::getdriverbyname("ESRI Shapefile")?; let dataset = gdalresourcefromdf(&df, &shapefiledriver, "/some/path/on/disk/myshapefile.shp", None)?; ```