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: u32EPSG code for the coordinate reference system.
overlap_size: usizeOverlap size between blocks.
block_size: BlockSizeBlock size for reading.
composition_bands: DimensionDimension for band composition.
composition_sources: DimensionDimension for source composition.
image_size: ImageSizeImage dimensions.
geo_transform: GeoTransformGeotransform parameters.
date_indices: Vec<DateType>Date indices for temporal data.
resolution: ImageResolutionImage resolution.
feature_collection: Option<ItemCollection>STAC feature collection.
na_value: TNo-data value.
layer_names: Vec<String>Layer names from DataSource.
Implementations§
Source§impl<T> RasterDatasetBuilder<T>where
T: RasterType,
impl<T> RasterDatasetBuilder<T>where
T: RasterType,
Sourcepub fn from_scratch<U>(
extent: Extent,
resolution: U,
epsg_code: u32,
block_size: BlockSize,
) -> RasterDataset<T>where
U: ToPrimitive + Debug,
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 structresolution- 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
);Sourcepub fn from_source(data_source: &DataSource) -> RasterDatasetBuilder<T>
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();Sourcepub fn from_item_collection(feature_collection: &ItemCollection) -> Self
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.
Sourcepub fn from_stac_query(feature_collection: &ItemCollection) -> Self
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:
set_epsg— Set the target coordinate reference systemset_resolution— Change the output pixel resolutionblock_size— Set the processing block size
§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();Sourcepub fn from_sources(data_sources: &Vec<DataSource>) -> RasterDatasetBuilder<T>
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();Sourcepub fn set_image_size(self, image_size: ImageSize) -> Self
pub fn set_image_size(self, image_size: ImageSize) -> Self
Sets the image size.
Sourcepub fn set_geo_transform(self, geo_transform: GeoTransform) -> Self
pub fn set_geo_transform(self, geo_transform: GeoTransform) -> Self
Set the desired geo_transform
Sourcepub fn set_resolution(self, resolution: ImageResolution) -> Self
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().
Sourcepub fn block_size(self, block_size: BlockSize) -> RasterDatasetBuilder<T>
pub fn block_size(self, block_size: BlockSize) -> RasterDatasetBuilder<T>
Sourcepub fn overlap_size(self, overlap_size: usize) -> RasterDatasetBuilder<T>
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.
Sourcepub fn source_composition_dimension(
self,
composition_dimension: Dimension,
) -> RasterDatasetBuilder<T>
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.
Sourcepub fn band_composition_dimension(
self,
composition_dimension: Dimension,
) -> RasterDatasetBuilder<T>
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.
Sourcepub fn set_date_indices(self, date_indices: &[DateType]) -> Self
pub fn set_date_indices(self, date_indices: &[DateType]) -> Self
Sets the date indices for temporal data.
Sourcepub fn bands(self, bands: HashMap<String, Vec<usize>>) -> Self
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.
Sourcepub fn set_template<V>(
self,
other: &RasterDataset<V>,
) -> RasterDatasetBuilder<T>where
V: RasterType,
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.
fn get_resolution(source: &Path) -> ImageResolution
fn get_geotransform(source: &Path) -> GeoTransform
fn get_max_extent(extents: Vec<Extent>) -> Extent
fn get_extent(source: &Path, target_epsg: u32) -> Extent
fn get_epsg_code(source: &Path) -> u32
fn get_blocks(
&self,
block_shape: RasterDataShape,
layers: &[Layer],
epsg_code: usize,
) -> Vec<RasterBlock<T>>where
T: RasterType,
fn n_block_cols(&self) -> usize
fn n_block_rows(&self) -> usize
fn n_blocks(&self) -> usize
fn block_from_id( &self, id: usize, block_shape: RasterDataShape, _layers: &[Layer], epsg_code: usize, ) -> RasterBlock<T>
fn block_col_row(&self, id: usize) -> (usize, usize)
Sourcepub fn build(self) -> RasterDataset<T>
pub fn build(self) -> RasterDataset<T>
Builds the RasterDataset.
Trait Implementations§
Source§impl<T> Default for RasterDatasetBuilder<T>where
T: RasterType + Default,
impl<T> Default for RasterDatasetBuilder<T>where
T: RasterType + Default,
Source§fn default() -> RasterDatasetBuilder<T>
fn default() -> RasterDatasetBuilder<T>
Auto Trait Implementations§
impl<T> Freeze for RasterDatasetBuilder<T>where
T: Freeze,
impl<T> RefUnwindSafe for RasterDatasetBuilder<T>where
T: RefUnwindSafe,
impl<T> Send for RasterDatasetBuilder<T>
impl<T> Sync for RasterDatasetBuilder<T>
impl<T> Unpin for RasterDatasetBuilder<T>where
T: Unpin,
impl<T> UnwindSafe for RasterDatasetBuilder<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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