基于生境异质性假说,用 NDVI 生产力、纹理结构异质性与地形粗糙度三类代理估算物种丰富度空间分布。Maps species richness proxies from NDVI, texture and terrain heterogeneity. 输出物种丰富度与生境质量 GeoTIFF + 参数 JSON。
Coding
geoskill-habitat-suitability-modeling
Try it由多变量环境栅格训练物种分布模型,输出 0-1 栖息地适宜性概率与变量贡献度。Models habitat suitability probability from environmental rasters with RF or logistic regression. 输出适宜性 GeoTIFF + 模型参数 JSON(含交叉验证 AUC)。
What it does
由多变量环境栅格训练物种分布模型,输出 0-1 栖息地适宜性概率与变量贡献度。Models habitat suitability probability from environmental rasters with RF or logistic regression. 输出适宜性 GeoTIFF + 模型参数 JSON(含交叉验证 AUC)。
The skill document
栖息地适宜性建模 | Habitat Suitability Modeling
Using environmental rasters such as temperature, precipitation, vegetation, and terrain as features, trains a species distribution model with random forest (rf) or logistic regression (logreg), outputs a habitat suitability probability in [0,1], and reports the relative contribution of each environmental variable (normalized to sum to 1). A built-in 3-fold cross-validated AUC serves as the measure of model discriminative ability.
Synthetic mode generates presence/absence labels from a known niche (NDVI-driven), allowing offline verification that the model correctly learns the dominant variable; real-input mode generates pseudo-presence from high-quantile suitability as an unsupervised fallback.
Dependencies / 依赖
pip install numpy rasterio scikit-learn scipy
Usage / 使用方法
Example 1: Synthetic Niche + Random Forest
python geoskill-habitat-suitability-modeling.py --bbox 116.0 39.0 117.0 40.0 --synthetic --model rf --output-dir ./output
Example 2: Logistic Regression (Linearly Interpretable)
python geoskill-habitat-suitability-modeling.py --bbox 116 39 117 40 --synthetic --model logreg --output-dir ./logreg
Example 3: Real Environmental Rasters (Each Band = One Environmental Variable)
python geoskill-habitat-suitability-modeling.py --input env_stack.tif --model rf --output-dir ./real
Example 4: Changing the Random Seed
python geoskill-habitat-suitability-modeling.py --bbox 121 31 122 32 --synthetic --seed 7 --output-dir ./seed7
Example 5: Quiet Mode
python geoskill-habitat-suitability-modeling.py --bbox 113 23 114 24 --synthetic --quiet --output-dir ./batch
Output / 输出
| File | Format | Description |
|---|---|---|
habitat_suitability.tif | GeoTIFF (float32) | Suitability probability ∈ [0,1], EPSG:4326 |
suitability_params.json | JSON | Model type, sample count, CV AUC, variable contributions |
output-manifest.json | JSON | Run manifest (input/output/QA/software versions) |
Data Source / 数据源 / Source
Local multi-band GeoTIFF (each band = an environmental variable); synthetic mode locally generates four layers (temperature/precipitation/NDVI/elevation) and known-niche labels, with no external data source.
Privacy / 隐私声明 / Privacy
- Runs fully offline by default and makes no network requests
--syntheticmode reads no external data- All computation is done locally; user data is never uploaded
License / License
MIT
name: geoskill-habitat-suitability-modeling description: '由多变量环境栅格训练物种分布模型,输出 0-1 栖息地适宜性概率与变量贡献度。Models habitat suitability probability from environmental rasters with RF or logistic regression. 输出适宜性 GeoTIFF + 模型参数 JSON(含交叉验证 AUC)。'
栖息地适宜性建模 | Habitat Suitability Modeling
以温度、降水、植被、地形等环境栅格为特征,训练随机森林(rf)或逻辑回归(logreg)物种分布模型,输出 0-1 的栖息地适宜性概率,并给出各环境变量的相对贡献(归一化和为 1)。内置 3 折交叉验证 AUC 作为模型判别能力度量。
合成模式按已知生态位(NDVI 驱动)生成 presence/absence 标签,可离线验证模型能否正确学到主导变量;真实输入模式用高分位适宜度生成伪 presence(unsupervised fallback)。
依赖
pip install numpy rasterio scikit-learn scipy
使用方法
示例 1:合成生态位 + 随机森林
python geoskill-habitat-suitability-modeling.py --bbox 116.0 39.0 117.0 40.0 --synthetic --model rf --output-dir ./output
示例 2:逻辑回归(线性可解释)
python geoskill-habitat-suitability-modeling.py --bbox 116 39 117 40 --synthetic --model logreg --output-dir ./logreg
示例 3:真实环境栅格(每个波段=一个环境变量)
python geoskill-habitat-suitability-modeling.py --input env_stack.tif --model rf --output-dir ./real
示例 4:更换随机种子
python geoskill-habitat-suitability-modeling.py --bbox 121 31 122 32 --synthetic --seed 7 --output-dir ./seed7
示例 5:静默模式
python geoskill-habitat-suitability-modeling.py --bbox 113 23 114 24 --synthetic --quiet --output-dir ./batch
输出
| 文件 | 格式 | 说明 |
|---|---|---|
habitat_suitability.tif | GeoTIFF (float32) | 适宜性概率 ∈ [0,1],EPSG:4326 |
suitability_params.json | JSON | 模型类型、样本数、CV AUC、变量贡献度 |
output-manifest.json | JSON | 运行清单(输入/输出/QA/软件版本) |
数据源 / Source
本地多波段 GeoTIFF(各波段=环境变量);合成模式本地生成温度/降水/NDVI/高程四层与已知生态位标签,无外部数据源。
隐私声明 / Privacy
- 默认完全离线运行,不发起任何网络请求
--synthetic模式不读取任何外部数据- 所有计算在本地完成,不上传用户数据
License
MIT
Related skills
多时相指数阈值分类检测入侵新增像元,计算面积相对扩散速率,用环境适宜性×距离衰减预测入侵风险。Monitors invasive species spread from multi-temporal classification and risk prediction. 输出新增入侵与风险 GeoTIFF。
多压力因子归一化加权叠加得综合影响指数,独立概率模型估算累积效应,按阈值划分5 级影响等级。Assesses environmental impact grades by multi-factor overlay and cumulative effects. 输出影响指数与等级 GeoTIFF。
Multi-criteria suitability analysis for infrastructure site selection. Use when the user wants to analyze changes, compare multi-temporal rasters, compute indices, or generate assessment reports.
由栖息地适宜性构建阻力面,Dijkstra 最小成本路径识别生态廊道,并计算 PC 景观连通性指数。Designs ecological corridors with least-cost paths and connectivity indices. 输出阻力面与廊道 GeoTIFF + 参数 JSON。
高斯烟羽模型模拟点源污染物浓度场,Pasquill-Gifford A-F 稳定度参数化 σy/σz,叠加 DEM 地形修正。Simulates pollutant concentration fields with a Gaussian plume model plus terrain correction. 输出浓度场 GeoTIFF + 参数 JSON。