1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
//! RasterDataset module for handling raster data.
/// Builder for constructing RasterDataset instances.
/// Implementation methods for RasterDataset.
/// Processing methods (apply, reduce, mosaic).
/// Rasterization methods.
/// Sampling and extraction methods.
/// ML methods (feature-gated).
/// Zonal statistics methods (feature-gated).
/// I/O methods (read_block, write_window3).
/// Composition methods (stack, extend).
use crateRasterType;
use crateRasterMetadata;
use crateRasterBlock;
use PathBuf;
// Re-export RasterDatasetBuilder from builder module
pub use RasterDatasetBuilder;
/// Main data structure of eorst. Stores the raster dataset [metadata](crate::RasterMetadata) and [blocks](crate::RasterBlock).
///
/// The easiest way to create a RasterDataset is by using [`RasterDatasetBuilder`]:
///
/// ```rust,ignore
/// use std::path::PathBuf;
/// use eorst::{types::BlockSize, RasterDatasetBuilder, DataSourceBuilder, RasterDataset};
///
/// let data_source = DataSourceBuilder::from_file(&PathBuf::from("scene.tif")).build();
/// let rds: RasterDataset<u16> = RasterDatasetBuilder::from_source(&data_source)
/// .block_size(BlockSize { cols: 2048, rows: 2048 })
/// .build();
/// ```
///
/// ## Processing with [`apply`](RasterDataset::apply)
///
/// [`apply`](RasterDataset::apply) is the main entry point. Pass a worker function
/// that receives a [`RasterDataBlock`] — the block data, metadata, and no-data value.
/// The worker returns an `Array4` which is written directly to the output GeoTIFF:
///
/// ```rust,ignore
/// use eorst::{RasterDataBlock, RasterDataset};
/// use anyhow::Result;
/// use ndarray::Array4;
///
/// fn worker(block: &RasterDataBlock<u16>) -> Result<Array4<i16>> {
/// let red = block.select_layers(&["red"])?;
/// let nir = block.select_layers(&["nir"])?;
/// let ndvi = ((&nir.data - &red.data) / (&nir.data + &red.data + 1e-10)) * 10000i16;
/// Ok(ndvi.cast::<i16>()?)
/// }
///
/// rds.apply::<i16>(worker, 8, &PathBuf::from("output.tif"))?;
/// ```
///
/// The [`Select`](crate::selection::Select) trait on `RasterDataBlock` lets you select
/// layers and time slices by name without tracking indices manually.
///
/// ## Alternative: Manual Block Iteration
///
/// You can also iterate over blocks manually:
///
/// ```rust,ignore
/// for iter in rds.iter() {
/// let block_id = iter.iter_index;
/// let block_data = rds.read_block::<i32>(block_id);
/// // ... process block_data directly
/// }
/// ```