Awesome Spectral Indices in Python - comprehensive library for computing spectral indices from remote sensing data
Comprehensive band definitions and platform-specific information for major satellite sensors used in remote sensing. Provides wavelength specifications, bandwidth information, and cross-platform compatibility mappings for standardized spectral band notation.
The global spyndex.bands object provides access to all band definitions used across spectral indices in the catalogue.
class Bands(Box):
"""
Container for all band definitions used in spectral indices.
Provides dictionary-like access to individual Band objects.
"""
def __repr__(self) -> str:
"""Machine readable representation showing available band names."""
def __str__(self) -> str:
"""Human readable list of band names."""Usage Examples:
import spyndex
# Access the global band catalogue
print(spyndex.bands)
# Output: Bands(['A', 'B', 'G', 'R', 'RE1', 'RE2', 'RE3', 'N', 'N2', 'S1', 'S2', 'T1', 'T2'])
# Get list of all band names
band_names = list(spyndex.bands.keys())
print(f"Total bands available: {len(band_names)}")
# Access specific bands
nir = spyndex.bands.N # Near-infrared
red = spyndex.bands.R # Red
green = spyndex.bands.G # Green
blue = spyndex.bands.B # BlueEach band is represented as a Band object containing spectral range information and platform-specific mappings.
class Band:
"""
Individual band definition with spectral range and platform mappings.
"""
short_name: str # Standard band abbreviation (e.g., "N", "R", "G")
long_name: str # Descriptive name (e.g., "Near Infrared", "Red")
common_name: str # STAC Electro-Optical Extension common name
min_wavelength: float # Minimum wavelength of spectral range (nm)
max_wavelength: float # Maximum wavelength of spectral range (nm)
standard: str # Standard abbreviation (alias for short_name)
# Platform-specific band information (conditionally present)
# Note: Only platforms that support this specific band will have corresponding attributes
sentinel2a: Optional[PlatformBand] # Sentinel-2A band details (if supported)
sentinel2b: Optional[PlatformBand] # Sentinel-2B band details (if supported)
landsat4: Optional[PlatformBand] # Landsat 4 band details (if supported)
landsat5: Optional[PlatformBand] # Landsat 5 band details (if supported)
landsat7: Optional[PlatformBand] # Landsat 7 band details (if supported)
landsat8: Optional[PlatformBand] # Landsat 8 band details (if supported)
landsat9: Optional[PlatformBand] # Landsat 9 band details (if supported)
modis: Optional[PlatformBand] # MODIS band details (if supported)
worldview2: Optional[PlatformBand] # WorldView-2 band details (if supported)
worldview3: Optional[PlatformBand] # WorldView-3 band details (if supported)
planetscope: Optional[PlatformBand] # PlanetScope band details (if supported)
def __repr__(self) -> str:
"""Machine readable representation with band name."""
def __str__(self) -> str:
"""Human readable band description."""Usage Examples:
import spyndex
# Access individual band
nir_band = spyndex.bands.N
# Explore band properties
print(nir_band.short_name) # "N"
print(nir_band.long_name) # "Near Infrared"
print(nir_band.common_name) # "nir"
print(nir_band.min_wavelength) # 760.0
print(nir_band.max_wavelength) # 1000.0
# Display band information
print(nir_band)
# Output: N: Near Infrared
# Check available platforms for a band
if hasattr(nir_band, 'sentinel2a'):
print("Available on Sentinel-2A")
if hasattr(nir_band, 'landsat8'):
print("Available on Landsat 8")Detailed band specifications for individual satellite platforms, including actual band identifiers, center wavelengths, and bandwidths.
class PlatformBand:
"""
Band information for a specific satellite platform.
"""
platform: str # Platform name (e.g., "Sentinel-2A", "Landsat 8")
band: str # Platform-specific band identifier (e.g., "B8", "B04")
name: str # Descriptive name for this platform
wavelength: float # Center wavelength in nanometers
bandwidth: float # Bandwidth in nanometers
def __repr__(self) -> str:
"""Machine readable representation with platform and band details."""
def __str__(self) -> str:
"""Human readable platform band description."""Usage Examples:
import spyndex
# Access platform-specific band information
nir_band = spyndex.bands.N
# Sentinel-2A NIR band details
s2a_nir = nir_band.sentinel2a
print(s2a_nir.platform) # "Sentinel-2A"
print(s2a_nir.band) # "B8"
print(s2a_nir.name) # "Near Infrared"
print(s2a_nir.wavelength) # 842.0
print(s2a_nir.bandwidth) # 106.0
# Display detailed information
print(s2a_nir)
# Output: Platform: Sentinel-2A, Band: Near Infrared
# * Band: B8
# * Center Wavelength (nm): 842.0
# * Bandwidth (nm): 106.0
# Compare across platforms
red_band = spyndex.bands.R
# Landsat 8 vs Sentinel-2A red bands
l8_red = red_band.landsat8
s2a_red = red_band.sentinel2a
print(f"Landsat 8 Red: {l8_red.wavelength}nm (±{l8_red.bandwidth/2}nm)")
print(f"Sentinel-2A Red: {s2a_red.wavelength}nm (±{s2a_red.bandwidth/2}nm)")Understanding how standardized band notation maps to different satellite platforms:
import spyndex
def show_band_mapping(band_name):
"""Display how a standard band maps across platforms."""
band = getattr(spyndex.bands, band_name)
print(f"\nStandard Band: {band.short_name} ({band.long_name})")
print(f"Wavelength Range: {band.min_wavelength}-{band.max_wavelength} nm")
print("\nPlatform Mappings:")
platforms = ['sentinel2a', 'sentinel2b', 'landsat8', 'landsat7', 'modis']
for platform in platforms:
if hasattr(band, platform):
pb = getattr(band, platform)
print(f" {pb.platform}: {pb.band} ({pb.wavelength}nm, ±{pb.bandwidth/2}nm)")
# Example usage
show_band_mapping('N') # Near-infrared
show_band_mapping('R') # Red
show_band_mapping('G') # GreenFinding compatible bands across different satellite platforms:
import spyndex
# Find bands available on specific platforms
def find_platform_bands(platform_name):
"""Find all bands available on a specific platform."""
available_bands = []
for band_name, band in spyndex.bands.items():
platform_attr = platform_name.lower().replace('-', '').replace(' ', '')
if hasattr(band, platform_attr):
available_bands.append((band_name, band.long_name))
return available_bands
# Example usage
s2a_bands = find_platform_bands('Sentinel-2A')
print(f"Sentinel-2A available bands: {len(s2a_bands)}")
for short, long in s2a_bands:
print(f" {short}: {long}")
# Find bands common to multiple platforms
def find_common_bands(*platforms):
"""Find bands available on all specified platforms."""
platform_attrs = [p.lower().replace('-', '').replace(' ', '') for p in platforms]
common_bands = []
for band_name, band in spyndex.bands.items():
if all(hasattr(band, attr) for attr in platform_attrs):
common_bands.append(band_name)
return common_bands
# Find bands available on both Sentinel-2A and Landsat 8
common = find_common_bands('Sentinel-2A', 'Landsat 8')
print(f"Common bands: {common}")Spyndex uses standardized single-letter band notation that maps to physical wavelength ranges:
The band catalogue includes mappings for:
Band objects provide both general wavelength ranges for the standard notation and precise platform-specific center wavelengths and bandwidths. This enables:
Install with Tessl CLI
npx tessl i tessl/pypi-spyndex