Read and write GDAL-compatible geospatial data into Polars and GeoPolars.
Supports reading and writing the following geospatial formats into / from a Polars Dataframe:
- GeoJSON
- ShapeFiles
- CSV with lat / lon
- FlatGeobuf
- KML
- GPX
- PostGIS (via network)
- SpatialLite
- ... and many more
Example 1: Dataframe from a file
use df_from_resource;
let df = df_from_resource.unwrap;
println!;
Example 2: DataFrame from raw bytes
use 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;
let df = df_from_bytes.unwrap;
println!;
Example 3: DataFrame from GDAL Layer with filtering query
use ;
use sql;
let dataset = open?;
let query = "SELECT kind, is_bridge, highway FROM my_shapefile WHERE highway = 'pedestrian'";
let mut result_set = dataset.execute_sql.unwrap.unwrap;
let df = df_from_layer.unwrap;
println!;
Example 4: DataFrame from Latitude / Longitude CSV with custom parsing options
let mut params = default;
let csv_parsing_options = ;
params.open_options = Some;
let df = df_from_resource.unwrap;
println!;
Example 5: DataFrame from a PostGIS table
use ;
let mut params = default;
params.layer_name = Some;
let df = df_from_resource.unwrap;
println!;
Example 6: GeoJSON bytes from a Dataframe
use ;
let df: DataFrame = ...;
let json_driver = get_driver_by_name?;
let geojson_bytes = gdal_bytes_from_df?;
Example 7: Write a shapefile to disk from a DataFrame
use ;
let df: DataFrame = ...;
let shapefile_driver = get_driver_by_name?;
let _dataset = gdal_resource_from_df?;