Struct RasterDatasetBuilder

Source
pub struct RasterDatasetBuilder<T>
where T: RasterType,
{
Show 15 fields pub sources: Vec<PathBuf>, pub bands: HashMap<String, Vec<usize>>, pub bands_vec: Vec<Vec<usize>>, pub epsg: u32, pub overlap_size: usize, pub block_size: BlockSize, pub composition_bands: Dimension, pub composition_sources: Dimension, pub image_size: ImageSize, pub geo_transform: GeoTransform, pub date_indices: Vec<DateType>, pub resolution: ImageResolution, pub feature_collection: Option<ItemCollection>, pub na_value: T, pub layer_names: Vec<String>,
}
Expand description

Main builder struct for constructing RasterDataset instances.

Fields§

§sources: Vec<PathBuf>

Source file paths.

§bands: HashMap<String, Vec<usize>>

Band indices per source.

§bands_vec: Vec<Vec<usize>>

Band indices as vector.

§epsg: u32

EPSG code for the coordinate reference system.

§overlap_size: usize

Overlap size between blocks.

§block_size: BlockSize

Block size for reading.

§composition_bands: Dimension

Dimension for band composition.

§composition_sources: Dimension

Dimension for source composition.

§image_size: ImageSize

Image dimensions.

§geo_transform: GeoTransform

Geotransform parameters.

§date_indices: Vec<DateType>

Date indices for temporal data.

§resolution: ImageResolution

Image resolution.

§feature_collection: Option<ItemCollection>

STAC feature collection.

§na_value: T

No-data value.

§layer_names: Vec<String>

Layer names from DataSource.

Implementations§

Source§

impl<T> RasterDatasetBuilder<T>
where T: RasterType,

Source

pub fn from_scratch<U>( extent: Extent, resolution: U, epsg_code: u32, block_size: BlockSize, ) -> RasterDataset<T>
where U: ToPrimitive + Debug,

Creates a RasterDataset from scratch (empty raster).

Creates a new empty raster dataset with the specified extent, resolution, and CRS. Useful for creating output rasters for rasterization or other operations that need a pre-defined grid.

§Arguments
  • extent - Geographic extent as Extent struct
  • resolution - Pixel size (will be converted to f64)
  • epsg_code - EPSG coordinate reference system code (e.g., 32755 for UTM zone 55S)
  • block_size - Size of processing blocks as BlockSize
§Example
use eorst::rasterdataset::RasterDatasetBuilder;
use eorst::metadata::Extent;
use eorst::types::BlockSize;

let extent = Extent { xmin: 0., ymin: 0., xmax: 1000., ymax: 1000. };
let block_size = BlockSize { cols: 256, rows: 256 };

let rds: RasterDataset<i32> = RasterDatasetBuilder::from_scratch(
    extent, 30.0, 32755, block_size
);
Source

pub fn from_source(data_source: &DataSource) -> RasterDatasetBuilder<T>

Creates a builder from a single data source.

Convenience method that wraps from_sources.

§Example
use eorst::rasterdataset::RasterDatasetBuilder;
use eorst::data_sources::DataSourceBuilder;

let data_source = DataSourceBuilder::from_file(&path_to_file).build();
let rds = RasterDatasetBuilder::from_source(&data_source).build();
Source

pub fn from_item_collection(feature_collection: &ItemCollection) -> Self

Creates a builder from a STAC item collection.

This is a convenience alias for from_stac_query.

Source

pub fn from_stac_query(feature_collection: &ItemCollection) -> Self

Creates a RasterDataset from a STAC item collection.

Downloads and mosaics imagery from a STAC ItemCollection. This is the primary way to load cloud-optimized satellite imagery from providers like DEA, Element84, or Planetary Computer.

The method finds the minimum extent of all images, reprojects and resamples as needed, and creates a unified dataset. Tiles with different EPSG codes are automatically reprojected to the target CRS. Resolution can also be changed.

Use builder methods to configure the output:

§Example
use eorst::rasterdataset::RasterDatasetBuilder;
use stac::ItemCollection;

let items: ItemCollection = /* ... from a STAC API query ... */;
let rds = RasterDatasetBuilder::from_stac_query(&items)
    .set_epsg(32755)          // UTM zone 55S
    .set_resolution(30.0)     // 30m resolution
    .block_size(BlockSize { cols: 2048, rows: 2048 })
    .build();
Source

pub fn from_sources(data_sources: &Vec<DataSource>) -> RasterDatasetBuilder<T>

Creates a builder from multiple data sources.

All sources must have the same shape and GeoTransform. They are stacked along the time or layer dimension depending on the composition settings.

§Example
use eorst::rasterdataset::RasterDatasetBuilder;
use eorst::data_sources::DataSourceBuilder;

let sources = vec![
    DataSourceBuilder::from_file(&PathBuf::from("scene_2023.tif")).build(),
    DataSourceBuilder::from_file(&PathBuf::from("scene_2024.tif")).build(),
];
let rds = RasterDatasetBuilder::from_sources(&sources)
    .block_size(BlockSize { cols: 2048, rows: 2048 })
    .build();
Source

pub fn set_epsg(self, epsg_code: u32) -> Self

Sets the desired EPSG code for the raster dataset.

If the source data has a different CRS, it will be automatically reprojected during build().

§Example
RasterDatasetBuilder::from_source(&data_source)
    .set_epsg(32755)  // UTM zone 55S
    .build()
Source

pub fn set_image_size(self, image_size: ImageSize) -> Self

Sets the image size.

Source

pub fn set_geo_transform(self, geo_transform: GeoTransform) -> Self

Set the desired geo_transform

Source

pub fn set_resolution(self, resolution: ImageResolution) -> Self

Sets the desired resolution for the raster dataset.

If the source data has a different resolution, it will be resampled during build().

Source

pub fn block_size(self, block_size: BlockSize) -> RasterDatasetBuilder<T>

Sets the block size for chunked raster operations.

Larger blocks reduce I/O overhead but use more memory. Default is 1024×1024. A good choice for Sentinel-2 data is 2048×2048.

§Example
RasterDatasetBuilder::from_source(&data_source)
    .block_size(BlockSize { cols: 2048, rows: 2048 })
    .build()
Source

pub fn overlap_size(self, overlap_size: usize) -> RasterDatasetBuilder<T>

Sets the overlap size for block-based reads.

Overlap pixels are included on all sides of each block, useful for neighborhood operations that require data from adjacent blocks.

Source

pub fn source_composition_dimension( self, composition_dimension: Dimension, ) -> RasterDatasetBuilder<T>

Sets the source composition dimension.

Controls how multiple data sources are arranged along the time/layer axes.

Source

pub fn band_composition_dimension( self, composition_dimension: Dimension, ) -> RasterDatasetBuilder<T>

Sets the band composition dimension.

Controls how bands from each source are arranged along the time/layer axes.

Source

pub fn set_date_indices(self, date_indices: &[DateType]) -> Self

Sets the date indices for temporal data.

Source

pub fn bands(self, bands: HashMap<String, Vec<usize>>) -> Self

Sets the band mapping.

Maps band names to their source band indices. Useful when working with multi-band files or semantic band names.

Source

pub fn set_template<V>( self, other: &RasterDataset<V>, ) -> RasterDatasetBuilder<T>
where V: RasterType,

Sets the template for the raster dataset.

Copies the image size and GeoTransform from another dataset, ensuring the output matches its geometry. The EPSG code is also copied.

Source

fn get_resolution(source: &Path) -> ImageResolution

Source

fn get_geotransform(source: &Path) -> GeoTransform

Source

fn get_max_extent(extents: Vec<Extent>) -> Extent

Source

fn get_extent(source: &Path, target_epsg: u32) -> Extent

Source

fn get_epsg_code(source: &Path) -> u32

Source

fn get_blocks( &self, block_shape: RasterDataShape, layers: &[Layer], epsg_code: usize, ) -> Vec<RasterBlock<T>>
where T: RasterType,

Source

fn n_block_cols(&self) -> usize

Source

fn n_block_rows(&self) -> usize

Source

fn n_blocks(&self) -> usize

Source

fn block_from_id( &self, id: usize, block_shape: RasterDataShape, _layers: &[Layer], epsg_code: usize, ) -> RasterBlock<T>

Source

fn block_col_row(&self, id: usize) -> (usize, usize)

Source

pub fn build(self) -> RasterDataset<T>

Builds the RasterDataset.

Trait Implementations§

Source§

impl<T> Default for RasterDatasetBuilder<T>
where T: RasterType + Default,

Source§

fn default() -> RasterDatasetBuilder<T>

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

impl<T> PolicyExt for T
where T: ?Sized,

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] only if self and other return Action::Follow. Read more
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns [Action::Follow] if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more