Coding

geoskill-bare-soil-mapping

Try it

融合裸土指数 BSI、亮度与局部纹理(裸土低对比度)阈值提取裸土/裸地分布,支持 Otsu 自动阈值,输出裸土 GeoTIFF、BSI 栅格与面积统计。Maps bare soil by fusing BSI, brightness and local texture.

What it does

融合裸土指数 BSI、亮度与局部纹理(裸土低对比度)阈值提取裸土/裸地分布,支持 Otsu 自动阈值,输出裸土 GeoTIFF、BSI 栅格与面积统计。Maps bare soil by fusing BSI, brightness and local texture.

The skill document

裸土/裸地制图 | Bare Soil Mapping

Fuses three complementary features to extract the distribution of bare soil/bare land, distinguishing bare soil from vegetation, urban built-up areas, and water bodies. Suitable for soil erosion baseline surveys, early identification of desertification, verification of exposed land at construction sites, and land cover mapping in arid regions.

Core algorithm:

  • BSI (Bare Soil Index): BSI = ((SWIR+Red) − (NIR+Blue)) / ((SWIR+Red) + (NIR+Blue)). Bare soil exhibits high reflectance in the red and shortwave infrared bands and relatively low reflectance in the near-infrared, yielding high BSI values; vegetation produces negative BSI values due to its high NIR reflectance.
  • Brightness: mean multi-band reflectance, used to exclude dark water bodies.
  • Texture: local standard deviation. Bare soil surfaces are homogeneous with low contrast, whereas urban areas are heterogeneous with high texture.
  • Thresholding: the membership values of the three features are multiplied to obtain a score in [0, 1]; --threshold auto applies the Otsu method for automatic thresholding, or an explicit float in [0, 1] can be given.

Supports --synthetic mode to generate physically consistent scenes containing bare soil, vegetation, urban areas, and water bodies (offline).

Dependencies / 依赖

pip install numpy rasterio scipy

Usage / 使用方法

Basic Usage (Synthetic Data + Automatic Threshold, Offline)

python geoskill-bare-soil-mapping.py --bbox 116.0 39.0 117.0 40.0 --synthetic --threshold auto --output-dir ./output

Example 1: Explicit Threshold

python geoskill-bare-soil-mapping.py \
    --bbox 116.0 39.0 117.0 40.0 \
    --synthetic --threshold 0.4 \
    --output-dir ./thr

Example 2: Adjusting the Texture Window

python geoskill-bare-soil-mapping.py \
    --bbox 116.0 39.0 117.0 40.0 \
    --synthetic --texture-size 7 \
    --output-dir ./tex

Example 3: Real Multi-band Imagery

python geoskill-bare-soil-mapping.py \
    --input scene.tif \
    --threshold auto \
    --output-dir ./real

Input band order: blue / green / red / nir / swir (at least 5 bands).

Output / 输出

FileFormatDescription
bare_soil.tifGeoTIFF (float32)Bare soil mask (1 = bare soil), EPSG:4326
bsi.tifGeoTIFF (float32)Bare Soil Index BSI [−1, 1]
bare_soil_area.jsonJSONPixel/area (m², ha, km²), proportion, applied threshold, mean BSI
output-manifest.jsonJSONRun manifest (inputs/outputs/QA/software versions)

Data Source / 数据源 / Source

  • Synthetic mode: generated locally, no external data source
  • Real mode: user-provided multi-band surface reflectance GeoTIFF (e.g., Landsat / Sentinel-2)

Privacy / 隐私声明 / Privacy

  • Runs fully offline by default; makes no network requests
  • All computation is performed locally; no user data is uploaded

License / License

MIT



name: geoskill-bare-soil-mapping description: '融合裸土指数 BSI、亮度与局部纹理(裸土低对比度)阈值提取裸土/裸地分布,支持 Otsu 自动阈值,输出裸土 GeoTIFF、BSI 栅格与面积统计。Maps bare soil by fusing BSI, brightness and local texture.'

裸土/裸地制图 | Bare Soil Mapping

融合三个互补特征提取裸土/裸地分布,把裸土与植被、城镇建筑、水体区分开。 适用于土壤侵蚀本底调查、荒漠化早期识别、建设用地裸地核查与干旱区地表覆盖制图。

核心算法:

  • BSI(裸土指数):BSI = ((SWIR+Red) − (NIR+Blue)) / ((SWIR+Red) + (NIR+Blue))。 裸土红光与短波红外高反射、近红外相对低,BSI 偏高;植被因 NIR 高而 BSI 为负。
  • 亮度(brightness):多波段反射率均值,用于排除暗色水体。
  • 纹理(texture):局部标准差。裸土表面均一、对比度低;城镇异质、纹理高。
  • 阈值化:三者隶属度相乘得到得分 [0,1];--threshold auto 用大津法(Otsu) 自动阈值,或显式给定 [0,1] 浮点数。

支持 --synthetic 模式生成含裸土/植被/城镇/水体的物理一致场景(离线)。

依赖

pip install numpy rasterio scipy

使用方法

基本用法(合成数据 + 自动阈值,离线)

python geoskill-bare-soil-mapping.py --bbox 116.0 39.0 117.0 40.0 --synthetic --threshold auto --output-dir ./output

示例 1:显式阈值

python geoskill-bare-soil-mapping.py \
    --bbox 116.0 39.0 117.0 40.0 \
    --synthetic --threshold 0.4 \
    --output-dir ./thr

示例 2:调整纹理窗口

python geoskill-bare-soil-mapping.py \
    --bbox 116.0 39.0 117.0 40.0 \
    --synthetic --texture-size 7 \
    --output-dir ./tex

示例 3:真实多波段影像

python geoskill-bare-soil-mapping.py \
    --input scene.tif \
    --threshold auto \
    --output-dir ./real

输入波段顺序:blue / green / red / nir / swir(至少 5 波段)。

输出

文件格式说明
bare_soil.tifGeoTIFF (float32)裸土掩膜(1=裸土),EPSG:4326
bsi.tifGeoTIFF (float32)裸土指数 BSI [−1,1]
bare_soil_area.jsonJSON像元/面积(m²、ha、km²)、占比、应用阈值、均值 BSI
output-manifest.jsonJSON运行清单(输入/输出/QA/软件版本)

数据源 / Source

  • 合成模式:本地生成,无外部数据源
  • 真实模式:用户提供多波段地表反射率 GeoTIFF(如 Landsat / Sentinel-2)

隐私声明 / Privacy

  • 默认完全离线运行,不发起任何网络请求
  • 所有计算在本地完成,不上传用户数据

License

MIT

Related skills

用热惯量法与 SAR Dubois 模型估算表层土壤湿度并划分干旱等级。Estimates surface soil moisture via thermal inertia and the SAR Dubois model, with drought grading.

1 installs

融合 NDVI 趋势(Sen 斜率/线性回归)、反照率与植被稀缺度,综合评分分级荒漠化(稳定/轻/中/重度),输出等级与趋势栅格、面积统计。Fuses NDVI trend (Sen/linear slope), albedo and vegetation scarcity to grade desertification.

基于生境异质性假说,用 NDVI 生产力、纹理结构异质性与地形粗糙度三类代理估算物种丰富度空间分布。Maps species richness proxies from NDVI, texture and terrain heterogeneity. 输出物种丰富度与生境质量 GeoTIFF + 参数 JSON。

由 NDVI 幂律异速生长方程估算地上生物量碳,叠加根茎比地下碳与类型化土壤碳密度。Estimates carbon stocks from biomass allometry and soil carbon density. 输出地上碳/土壤碳/总碳三张 GeoTIFF 与汇总 JSON。

SAR 土壤湿度反演:基于简化 Dubois/Oh 半经验模型,由后向散射系数 σ⁰、入射角与地表粗糙度解析反演裸土体积含水量 (m³/m³)

1 installs

融合 CWSI 水分胁迫、红边叶绿素与 SAR 含水量,检测作物胁迫等级。Detects crop stress by fusing CWSI water stress, red-edge chlorophyll and SAR water content.