Skip to content

Repository files navigation

Lunar Crater Detection Pipeline

ind aff

Boundary detection of dispersal impact craters based on morphological characteristics, using lunar Digital Elevation Model (DEM) data.

Based on: Liu et al. (2017) — Boundary Detection of Dispersal Impact Craters Based on Morphological Characteristics Using Lunar Digital Elevation Model.

Pipeline Stages

  1. D8 Flow Direction — Computes ArcGIS-style flow directions from DEM
  2. Raw Crater Regions — Identifies depressions via priority-flood sink filling and D8 watershed expansion
  3. Shape Classification — Classifies regions as strip / radial / suborbicular / square (§III-B)
  4. Independent Craters — Filters false craters using posture ratio, rectangle factor, and sink validation (§III-C)
  5. Affiliated Craters — Detects dispersal crater rims via profile analysis and inflection point detection (§III-D)

Code Files

  • core.py — D8 flow direction computation
  • preprocess.py — Sink filling (priority-flood) and depression core labeling
  • depression.py — Depression identification, basin expansion, and morphological metrics
  • false_crater_filter.py — Independent crater filtering (§III-C)
  • affiliated.py — Affiliated dispersal crater detection with profile analysis (§III-D)
  • cli.py — CLI entry point for the full pipeline
  • io.py — Raster and GeoJSON I/O utilities
  • validate.py — D8 flow direction validation
  • directions.py — D8 neighbor encoding constants
  • _numba.py — Optional Numba JIT acceleration

Usage

# Full pipeline (generates all outputs)
python -m code.cli <DEM.tif> --paper-shortcut

# D8 flow direction only
python -m code.cli <DEM.tif> <output_flow.tif>

Key Detection Thresholds (defaults)

Parameter Default CLI Flag Purpose
Min crater depth 7.0 m --crater-min-depth Fill-depth threshold for a cell to be classified as a crater sink
Min region size 9 cells --min-region-cells Minimum watershed-expanded basin area
Max posture ratio 1.12 --posture-ratio Max L/W ratio for shape acceptance (strip vs. radial)
Sink-fill method priority-flood --preprocess-method Algorithm used for hydrological conditioning

Dataset Specifications

Input DEM

Property Requirement
Format GeoTIFF (.tif) — single-band, 32-bit float
Data type Elevation in metres (float32 / float64)
CRS Any projected CRS with metric units; pixel size is read directly from the raster transform
Nodata Any sentinel value or NaN; auto-detected from raster metadata, overridable via --nodata
Band count Single band (band 1 is read)
Minimum size ≥ 3 × 3 cells (smaller grids skip sink-filling)

Source: The pipeline was designed and validated against the Lunar Reconnaissance Orbiter Camera (LROC) NAC DEM tiles, as used in Liu et al. (2017). Any single-band elevation raster with consistent metric units will work.

📦 Datasets: bhargav247/DIP26_G01_Datasets on Hugging Face

File Resolution & Cell Size

  • Cell size is derived from the affine transform (|a| for x, |e| for y).
  • Can be overridden via --cellsize-x and --cellsize-y for rasters without a valid transform.
  • D8 flow direction uses the true diagonal distance √(cellsize_x² + cellsize_y²) for slope comparison.

Output Files

File Type Description
<prefix>_flow.tif GeoTIFF uint8 D8 flow direction (ArcGIS encoding: 1/2/4/8/16/32/64/128)
raw_crater_regions.tif GeoTIFF int32 All watershed-expanded depression labels
crater_regions_strip.tif GeoTIFF int32 Strip-classified regions
crater_regions_radial.tif GeoTIFF int32 Radial-classified regions
crater_regions_suborbicular.tif GeoTIFF int32 Suborbicular regions
crater_regions_square.tif GeoTIFF int32 Square-classified regions
crater_labels_independent.tif GeoTIFF int32 False-crater-filtered independent craters
crater_rims_independent.geojson GeoJSON Independent crater rim polygons with metrics
affiliated_analysis.geojson GeoJSON Profile lines, inflection points, hulls
crater_rims_affiliated.geojson GeoJSON Final affiliated crater rims

About

Python pipeline for lunar crater rim detection from DEMs using D8 flow routing, sink filling, morphology filters, and profile-based rim refinement (Liu et al. 2017).

Topics

Resources

Stars

1 star

Watchers

0 watching

Forks

Contributors

Languages