Import Tools
Overview
The import_tools module acts as the definitive data ingestion gateway and multi-spectral parsing core for the FEZrs processing engine. High-resolution commercial sensors (e.g., GeoEye, WorldView) and public science constellations (e.g., Landsat 8/9, Sentinel-2) employ fundamentally different data distribution architectures: commercial payloads typically bundle overlapping spectral channels into unified, multi-band raster arrays, whereas public science programs distribute independent spectral bands as discrete, single-channel raster products.
This module unifies these disparate payload formats, normalizing uneven radiometric bit-depths and assembling structurally synchronized tensor cubes. It transforms raw orbital observations into optimized 2D and 3D spatial grids calibrated for immediate downstream geometric partitioning, advanced feature engineering, or direct visual observation.
[Raw Commercial Imagery] [Raw Public Science Imagery]
Unified Multi-Band GeoTIFF Discrete Single-Band Files
│ │
▼ ▼
Geoeye_Calculator Landsat8_Calculator
│ │
▼ ▼
[Radiometric Normalization] [Dynamic Spectral Compositing]
$I_{\text{norm}} \in [0.0, 1.0]$ $\vec{P}(x, y) = [R, G, B]^T$
│ │
└──────────────────────┬──────────────────────┘
│
▼
[Downstream FEZrs Core Compute]
(glcm, hsv, enhancement, etc.)Comprehensive Class Specifications
Geoeye_Calculator (Unified Multi-Band Tensor Slicing)
Scientific and Engineering Objective
Geoeye_Calculator ingests high-resolution satellite scenes distributed as a single, multi-band file structure. Its objective is to linearly normalize the entire spatial data cube and extract an isolated, 2D spectral band based on a zero-indexed channel allocation. This provides an unwarped, scale-invariant spatial array ready for localized texture profiling or edge-detection filters.
Technical Foundation & Mathematical Formulations
Linear Radiometric Normalization
The array ingestion engine calls self.files_handler.get_normalized_bands(requested_bands=["tif"]) to extract the raster grid. The sub-system evaluates the metadata to determine the sensor's native hardware bit-depth (e.g., 11-bit high-fidelity quantization for GeoEye-1, or standard 16-bit engineering layouts). It then rescales the raw digital numbers () via linear division:
Where represents the internal channel dimension. This transformation scales the array values to a normalized floating-point range:
This conversion leverages skimage.img_as_float to enforce high-precision np.float64 floating-point representations while preserving the sensor's underlying radiometric resolution.
Vectorized Tensor Slicing
The normalized data cube is formatted as a 3D tensor with spatial and spectral dimensions:
To isolate a target band without introducing processing overhead or memory allocation leaks, the class applies a zero-indexed slicing operation along the third axis at the specified layer value ():
This operation isolates a 2D spatial array of dimensions that contains the normalized reflectance values measured by the sensor.
Interface Architecture
Constructor Method (
__init__) Input Arguments:tif_path(str|Path): Absolute system path pointing to the source multi-band GeoTIFF file.level(int): The zero-based integer index of the target spectral band to extract (e.g., identifies the first spectral band). Default setting is0.
Operational Validation (
_validate): Reads the tensor shape along the spectral dimension to determine . It verifies that the requested band index falls within valid bounds:
If the requested index is out of bounds, the method raises a ValueError to prevent invalid memory access or segmentation faults.
- Return State (
process()): Returns a single-channel 2Dnumpy.ndarray(np.float64) containing normalized values scaled between .
from pathlib import Path
from fezrs.tools.import_tools import Geoeye_Calculator
# Instantiate the multi-band extraction engine
# Extracting index 3 isolates the Near-Infrared (NIR) channel in standard 4-band payloads
sensor_extractor = Geoeye_Calculator(
tif_path=Path("./data/geoeye_subscene_4b.tif"),
level=3
)
# Execute the tensor slicing pipeline
normalized_channel = sensor_extractor.process()Landsat8_Calculator (Discrete Multi-Spectral Composition)
Scientific and Engineering Objective
Landsat8_Calculator ingests separate single-band raster files and coordinates their spatial alignment into custom multi-band color composites. It maps distinct spectral wavelengths to the standard red, green, and blue () display channels, helping human analysts identify specific surface features or preparing consistent data stacks for machine learning workflows.
Technical Foundation & Mathematical Formulations
Vectorized Layer Stacking
The engine ingests separate spatial bands of identical resolution and uses a vectorized stacking operation to generate a combined multi-channel array. It aligns the three assigned 2D channel arrays (, , and ) along the third tensor dimension using NumPy's optimized np.stack execution layer:
This transformation packs the independent 2D arrays into a continuous 3D coordinate mesh of shape . For every coordinate pair , the pixel values are represented as a localized multi-spectral vector:
Analytical Compositing Modes
The internal mapping architecture supports three compositing profiles via the exportType parameter:
┌──────────────────────────────┐
│ exportType Match │
└──────────────┬───────────────┘
│
┌───────────────────────┼───────────────────────┐
▼ ▼ ▼
[None] ["rgb"] ["infrared"]
Raw DN Stack Normalized True-Color Short-Wave IR Composite
R: Band 4 (Red) R: Normalized B4 R: Normalized B7 (SWIR2)
G: Band 3 (Green) G: Normalized B3 G: Normalized B6 (SWIR1)
B: Band 2 (Blue) B: Normalized B2 B: Normalized B5 (NIR)Profile A: Raw Digital Number Stack (exportType=None)
Combines the raw visible bands directly without applying radiometric corrections. This mode preserves the original integer digital numbers (), which are typically formatted as uint16 data structures.
Profile B: Normalized True-Color (exportType="rgb")
Applies linear scaling to the visible bands before compositing. This maps the natural color spectrum to the normalized floating-point range , enhancing contrast for visual interpretation.
Profile C: Short-Wave False-Color Infrared (exportType="infrared")
Constructs an advanced infrared composite by shifting invisible short-wave and near-infrared wavelengths into the visible color space. This combination is highly effective for identifying changes in vegetation health, mapping burn scars, and tracking soil moisture anomalies.
Spectral Rationale for Infrared Compositing
The mapping logic used in "infrared" mode is specifically tailored to the physical interaction of light with different surface materials:
SWIR2 () Red Channel: Water molecules strongly absorb short-wave infrared energy, whereas dry soils, exposed rock, and active burn scars reflect it highly. This ensures that dry or fire-damaged surfaces show up clearly in the red spectrum.
SWIR1 () Green Channel: This band is highly sensitive to inner leaf moisture and cellular gaps, tracking structural variations in the landscape.
NIR () Blue Channel: The spongy mesophyll tissue in healthy plant leaves strongly reflects near-infrared light. Consequently, areas with dense, active vegetation stand out vividly as cyan and blue features.
Analytical Compositing Reference Matrix
The table below summarizes the technical specifications and application profiles for the different compositing modes:
| Composite Mode Selection | Internal Band Routing Diagram | Data Type | Radiometric Scale Bounds | Primary Remote Sensing Use Cases |
|---|---|---|---|---|
None (Raw Stack) | uint16 | Preserves raw unscaled calibration data for basic archive ingestion. | ||
"rgb" (True Color) | float64 | General visual mapping, urban planning, and baseline land-surface profiling. | ||
"infrared" (False Color) | float64 | Mapping burn boundaries, tracking forest fire severity, and monitoring agricultural crop stress. |

