moonbit-cog

Cloud-Optimized GeoTIFF and Multispectral Remote Sensing Engine in MoonBit

geotiff
remote-sensing
raster
cog
gis
wasm
moon add Mostan-303/moonbit-cog@0.2.0
Download zip
Version
0.2.0
License
Apache-2.0
Last updated
12 hours ago
Downloads
1
README

#moonbit-cog

moonbit-cog is a native MoonBit engine for Cloud-Optimized GeoTIFF (COG), raster algebra, multispectral indices, terrain analysis, and cloud-friendly byte-range planning. It is designed for reproducible geospatial processing across native and WebAssembly targets without external C/C++ runtime dependencies.

CI License

#Applications

  • Inspect and decode TIFF 6.0 and BigTIFF metadata, GeoKeys, tiles, strips, and overview layouts.
  • Process Sentinel-2/Landsat-style multispectral scenes with NDVI, water, burn, soil, and moisture indices.
  • Run raster map algebra, focal filters, resampling, classification, DEM terrain, and hydrology operations.
  • Plan deterministic HTTP byte ranges for tiled COG windows before remote tile retrieval.
  • Build native command-line workflows or reuse individual packages from MoonBit applications.

#Capabilities

The implementation includes TIFF/BigTIFF decoding and encoding, LZW/Deflate/PackBits decompression, affine georeferencing, raster statistics, spectral operators, spatial indexing, STAC catalog structures, terrain and hydrology analysis, and validation utilities. The RasterWindow API clips requests safely and preserves affine scale, skew, and shifted origin while returning statistics that ignore NoData and non-finite samples.

let request = @raster.RasterWindow::new(128, 64, 512, 512)
match @raster.analyze_window(grid, request) {
Some(analysis) => println(analysis.statistics.mean.to_string())
None => println("window has no intersection")
}

#Package map

AreaPackages
File formatstiff, encoder, compression, geokeys, crs, geotiff_exif
Raster and indicesraster, indices, spectral, pipeline, stats, analysis
Spatial processingspatial_ops, spatial_statistics, indexing, tiling, morphology
Terrain and qualitydem, hydrology, quality_control, validation_suite
Cloud and catalogscloud_optim, cog_validator, stac, stac_catalog
Tools and outputcli, main, reports, visualization, benchmark

#Quick start

Install the current MoonBit stable toolchain, then run:

moon update moon fmt --check moon check --deny-warn moon test --deny-warn moon build --target native src/main moon run --target native src/main -- help

Run the measured NDVI benchmark:

moon run --target native src/main -- bench 512 512

The report contains the dimensions, iteration count, measured algorithm elapsed time, throughput in megapixels per second, and a deterministic checksum. Reproducible local captures are recorded in BENCHMARKS.md.

#Verification and supported targets

The CI workflow checks formatting, package metadata, all-target compilation, and all-target tests with warnings denied. Local equivalents are:

moon version --all moon update moon fmt --check moon check --target all --deny-warn moon test --target all --deny-warn moon fmt && git diff --exit-code moon info && git diff --exit-code

The codebase is organized for MoonBit native, wasm, wasm-gc, and js targets where the selected package and runtime support them. Native execution is the reference path for the CLI benchmark.

#Source accounting

Implementation scale is measured from non-test .mbt files under src/, excluding blank lines and full-line comments. Generated interfaces and build output are not counted. Re-run this PowerShell command from the repository root for an auditable count:

$files = Get-ChildItem src -Recurse -Filter *.mbt | Where-Object { $_.Name -notmatch '_test\.mbt$' } $lines = $files | Get-Content | Where-Object { $t = $_.Trim() $t.Length -gt 0 -and $t -notmatch '^//' -and $t -notmatch '^///\|' } ($lines | Measure-Object).Count

#Benchmark methodology

Each benchmark run executes the synthetic Sentinel-2 NDVI pipeline three times. elapsed_ms is measured around those iterations with moonbitlang/core/env.now; throughput is total processed pixels divided by measured seconds; checksum is the sum of NDVI means across iterations. A machine-specific process timing and the exact command output belong in BENCHMARKS.md.

#License

Licensed under the Apache-2.0 License.

For Chinese documentation, see README_ZH.md.

Powered by MoonBit

Site sourceReport issuePackagesBuild queueSkillsStatistics

© 2026 mooncakes.io