Expand description
§rusterize
rusterize is an extremely fast, trait-based, rasterization engine for geo::Geometry.
Geometries can be rasterized as a DenseArray (a materialized raster) or a SparseArray, containing the band/row/col value triplets
of all lazily burned pixels. A SparseArray can later be materialized into a raster, therefore avoiding large memory allocations
until it’s actually needed.
§Installation
[dependencies]
rusterize-rs = "0.1"To include polars support:
[dependencies]
rusterize-rs = { version = "0.1", features = ["polars"] }§Example
Build a RasterInfo describing the output grid, wrap it in a RasterizeContext, then call rasterize on any slice of geometries.
The target type (DenseArray or SparseArray) selects the output encoding and data type. The PixelFunction dictates what happens
to overlapping pixels. FieldSource represents the values to be burned.
use rusterize::prelude::*;
use geo::{Geometry, Point};
fn example() -> RusterizeResult<()> {
let raster_info = RasterInfoBuilder::new()
.extent(0.0, 0.0, 10.0, 10.0)
.resolution(1.0, 1.0)
.build()?;
let geoms = vec![Geometry::Point(Point::new(5.0, 5.0)), Geometry::Point(Point::new(3.0, 3.0))];
let ctx = RasterizeContext {
raster_info,
field: FieldSource::Scalar(1.0_f64),
by: None,
pixel_fn: PixelFunction::Last,
background: f64::NAN,
all_touched: false,
};
let raster = geoms.rasterize::<DenseArray<f64>>(ctx)?;
Ok(())
}§Feature flags
polars: AddsFieldSource::Columnfor burning apolarscolumn.
Structs§
- Dense
Array - A materialized 3-dimensional array containing the burned geometries and spatial information.
- Raster
Info - Contains the spatial information associated with the burned
geo::Geometry. - Raster
Info Builder - Builder for a
RasterInfoinstance. If extent is not provided, it can be inferred from thegeo::Geometrywhen building it. In this case, a half-pixel buffer is applied to avoid missing points on the border. The logics dictating the final spatial properties of the rasterized geometries follow those of GDAL. - Rasterize
Context - Spatial + value context handed to the rasterization engine.
- Sparse
Array - A sparse array in COOordinate format storing the band/row/col value triplets.
of all burned
geo::Geometry.
Enums§
- Field
Source - Source of values to burn onto a
DenseArrayorSparseArray. - Pixel
Function - Supported functions to apply to overlapping pixels.
- Rusterize
Error
Traits§
- Array
Builder DenseArrayorSparseArraycreation trait.- NaNAware
- Trait to handle NaN check for dtypes that don’t have it.
- Polars
Handler - Handle polars dtypes and conversions.
- Raster
Dtype - Bound rasterization to a dtype.
- Rasterize
- Rasterization trait. Attaches to anything that can be viewed as a
geo::Geometryslice and produces aDenseArrayor aSparseArray.