Install
openclaw skills install @ruiduobao/forest-carbon-estimateEstimate forest carbon stock from remote sensing data using BEF, allometric equations, or IPCC Tier 1/2 methods. Includes Monte Carlo uncertainty analysis. Supports raster (GeoTIFF) and tabular (CSV) inputs.
openclaw skills install @ruiduobao/forest-carbon-estimateEstimate forest carbon stock from remote sensing data using multiple methods with uncertainty analysis.
# Single-point estimate (allometric)
python scripts\forest-carbon-estimate.py estimate --method allometric --height 15 --forest-type tropical
# Single-point estimate (BEF)
python scripts\forest-carbon-estimate.py estimate --method bef --agb 200 --forest-type temperate
# IPCC Tier 1 default
python scripts\forest-carbon-estimate.py estimate --method ipcc --forest-type boreal --area-ha 100
# Raster processing
python scripts\forest-carbon-estimate.py estimate --input height.tif --method allometric --output carbon.tif
# Uncertainty analysis
python scripts\forest-carbon-estimate.py uncertainty --method allometric --height 15 --iterations 5000
# Report from CSV
python scripts\forest-carbon-estimate.py report --input carbon_stock.csv
| Parameter | Description | Default |
|---|---|---|
--input | Input GeoTIFF or CSV | None (single-point) |
--method | Estimation method | allometric |
--forest-type | Forest type for default factors | default |
--height | Forest height (m) for allometric | None |
--agb | Above-ground biomass (t/ha) for BEF | None |
--area-ha | Area in hectares (IPCC) | 1.0 |
--agb-band | Band number for raster input | 1 |
--iterations | Monte Carlo iterations | 1000 |
--output | Output file path | Auto-generated |
AGB (Above-ground biomass)
↓
BGB = AGB × root_shoot_ratio (default 0.26)
↓
Total biomass = AGB + BGB
↓
Carbon stock = Total biomass × carbon_fraction (default 0.47)
| Method | Input | Description |
|---|---|---|
| BEF | AGB (t/ha) | Total biomass = AGB × BEF |
| Allometric | Height (m) | AGB = a × H^b |
| IPCC | Forest type | Default density from IPCC tables |
pip install requests>=2.28.0 tqdm numpy scipy rasterio
# Or: pip install -r scripts/requirements.txt
| Package | Purpose |
|---|---|
numpy | Numerical computation and Monte Carlo |
rasterio | GeoTIFF I/O for raster mode |
scipy | Statistical functions |
requests | Data download (if applicable) |
tqdm | Progress bars |
| Forest Type | BEF Range |
|---|---|
| Tropical | 1.5 – 3.0 |
| Temperate | 1.2 – 1.8 |
| Boreal | 1.0 – 1.5 |
| Mangrove | 1.2 – 1.8 |
Default BEF = 1.32 (temperate mixed forest). Adjust with --bef parameter.
For AGB = a × H^b (H = forest height in m):
| Forest Type | a | b |
|---|---|---|
| Tropical | 0.0673 | 0.976 |
| Temperate | 0.0592 | 1.030 |
| Boreal | 0.0450 | 1.050 |
These are DBH-based defaults. For height-based allometry, use --coeff-a and --coeff-b to override.
| Forest Type | Wood Density (g/cm³) |
|---|---|
| Tropical | 0.57 – 0.69 |
| Temperate | 0.41 – 0.56 |
| Boreal | 0.38 – 0.51 |
Default: 0.55 g/cm³. Override with --wood-density.
| Method | Best For | Input Required |
|---|---|---|
| BEF | Forest inventory data | AGB (t/ha) |
| Allometric | Remote sensing (LiDAR/InSAR height) | Forest height (m) |
| IPCC Tier 1 | Quick estimates, no field data | Forest type + area |
Carbon stock is reported in Mg C/ha (megagrams of carbon per hectare), equivalent to t C/ha.
For total stock: multiply by area (ha) → total Mg C.
Nodata pixels in input rasters are skipped. Output GeoTIFF uses the same nodata value as input. No interpolation is performed on nodata areas.
# Custom carbon fraction and root-shoot ratio
python scripts\forest-carbon-estimate.py estimate --method bef --agb 200 --forest-type temperate --carbon-fraction 0.45 --root-shoot-ratio 0.28
| Parameter | Default | Description |
|---|---|---|
--carbon-fraction | 0.47 | Carbon fraction of dry biomass |
--root-shoot-ratio | 0.26 | Root-to-shoot ratio |
--bef | 1.32 | Biomass expansion factor |
{
"mean": 125.3,
"std": 18.7,
"CI95_lower": 88.6,
"CI95_upper": 162.0
}
| Field | Description |
|---|---|
mean | Mean carbon stock estimate (Mg C/ha) |
std | Standard deviation from Monte Carlo |
CI95_lower | 95% confidence interval lower bound |
CI95_upper | 95% confidence interval upper bound |
Obtain forest height/AGB rasters from:
@book{ipcc2006guidelines,
title={2006 IPCC Guidelines for National Greenhouse Gas Inventories},
author={{IPCC}},
year={2006},
publisher={Institute for Global Environmental Strategies},
url={https://www.ipcc-nggip.iges.or.jp/public/2006gl/}
}
@book{ipcc2019refinement,
title={2019 Refinement to the 2006 IPCC Guidelines for National Greenhouse Gas Inventories},
author={{IPCC}},
year={2019},
publisher={IPCC},
url={https://www.ipcc-nggip.iges.or.jp/public/2019rf/}
}
import rasterio
import matplotlib.pyplot as plt
import numpy as np
with rasterio.open("carbon.tif") as src:
carbon = src.read(1)
nodata = src.nodata
carbon_plot = np.where(carbon == nodata, np.nan, carbon)
fig, ax = plt.subplots(figsize=(10, 8))
im = ax.imshow(carbon_plot, cmap="Greens", vmin=0, vmax=200)
cbar = plt.colorbar(im, ax=ax, shrink=0.8)
cbar.set_label("Carbon Stock (Mg C/ha)")
ax.set_title("Forest Carbon Stock")
ax.axis("off")
plt.tight_layout()
plt.savefig("carbon_map.png", dpi=200)
| Error | Cause | Solution |
|---|---|---|
ConnectionError | Network issue | Check internet, retry |
HTTP 429 | Rate limit | Wait 60s, retry |
ValueError | Invalid input | Check parameter format |
| Empty output | No data | Try different parameters |
ModuleNotFoundError | Missing dep | Run pip install |
for year in 2020 2021 2022 2023; do
python scripts\forest-carbon-estimate.py estimate --input agb_${year}.tif --method allometric --output carbon_${year}.tif
done
# .github/workflows/carbon-update.yml
name: Forest Carbon Update
on:
schedule:
- cron: '0 0 1 1 *' # Yearly
jobs:
estimate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: '3.11'
- run: pip install numpy rasterio
- run: |
python scripts\forest-carbon-estimate.py estimate \
--input data/agb_latest.tif \
--method allometric \
--output data/carbon_latest.tif
raster2pgsql -s 4326 -I -C carbon_latest.tif public.forest_carbon | psql -d gis_db
--method bef is fastest for regional estimates; --method allometric for species-specific--carbon-fraction 0.47 to match local species (default 0.47 = IPCC default)--window parameter基于遥感数据估算森林碳储量,支持 BEF、异速生长方程、IPCC Tier 1/2 三种方法,含蒙特卡洛不确定性分析。
pip install requests>=2.28.0 tqdm numpy scipy rasterio
# 或: pip install -r scripts/requirements.txt
| 包 | 用途 |
|---|---|
numpy | 数值计算和蒙特卡洛 |
rasterio | 栅格模式 GeoTIFF 读写 |
scipy | 统计函数 |
requests | 数据下载(如适用) |
tqdm | 进度条 |
| 森林类型 | BEF 范围 |
|---|---|
| 热带 | 1.5 – 3.0 |
| 温带 | 1.2 – 1.8 |
| 寒带 | 1.0 – 1.5 |
| 红树林 | 1.2 – 1.8 |
默认 BEF = 1.32(温带混交林)。使用 --bef 参数调整。
AGB = a × H^b(H = 树高,单位 m):
| 森林类型 | a | b |
|---|---|---|
| 热带 | 0.0673 | 0.976 |
| 温带 | 0.0592 | 1.030 |
| 寒带 | 0.0450 | 1.050 |
这些是基于 DBH 的默认值。树高异速生长使用 --coeff-a 和 --coeff-b 覆盖。
| 森林类型 | 木材密度 (g/cm³) |
|---|---|
| 热带 | 0.57 – 0.69 |
| 温带 | 0.41 – 0.56 |
| 寒带 | 0.38 – 0.51 |
默认:0.55 g/cm³。使用 --wood-density 覆盖。
| 方法 | 适用场景 | 所需输入 |
|---|---|---|
| BEF | 森林资源清查数据 | AGB (t/ha) |
| 异速生长 | 遥感(LiDAR/InSAR 树高) | 树高 (m) |
| IPCC Tier 1 | 快速估算,无野外数据 | 森林类型 + 面积 |
碳储量以 Mg C/ha(兆克碳/公顷)报告,等同于 t C/ha。
总储量:乘以面积(ha)→ 总 Mg C。
输入栅格中的 NoData 像元被跳过。输出 GeoTIFF 使用与输入相同的 nodata 值。不对 NoData 区域进行插值。
# 自定义碳分数和根冠比
python scripts\forest-carbon-estimate.py estimate --method bef --agb 200 --forest-type temperate --carbon-fraction 0.45 --root-shoot-ratio 0.28
| 参数 | 默认值 | 说明 |
|---|---|---|
--carbon-fraction | 0.47 | 干生物量碳分数 |
--root-shoot-ratio | 0.26 | 根冠比 |
--bef | 1.32 | 生物量扩展因子 |
{
"mean": 125.3,
"std": 18.7,
"CI95_lower": 88.6,
"CI95_upper": 162.0
}
| 字段 | 说明 |
|---|---|
mean | 碳储量估算均值 (Mg C/ha) |
std | 蒙特卡洛标准差 |
CI95_lower | 95% 置信区间下界 |
CI95_upper | 95% 置信区间上界 |
从以下渠道获取森林树高/AGB 栅格:
@book{ipcc2006guidelines,
title={2006 IPCC Guidelines for National Greenhouse Gas Inventories},
author={{IPCC}},
year={2006},
publisher={Institute for Global Environmental Strategies},
url={https://www.ipcc-nggip.iges.or.jp/public/2006gl/}
}
@book{ipcc2019refinement,
title={2019 Refinement to the 2006 IPCC Guidelines for National Greenhouse Gas Inventories},
author={{IPCC}},
year={2019},
publisher={IPCC},
url={https://www.ipcc-nggip.iges.or.jp/public/2019rf/}
}
import rasterio
import matplotlib.pyplot as plt
import numpy as np
with rasterio.open("carbon.tif") as src:
carbon = src.read(1)
nodata = src.nodata
carbon_plot = np.where(carbon == nodata, np.nan, carbon)
fig, ax = plt.subplots(figsize=(10, 8))
im = ax.imshow(carbon_plot, cmap="Greens", vmin=0, vmax=200)
cbar = plt.colorbar(im, ax=ax, shrink=0.8)
cbar.set_label("碳储量 (Mg C/ha)")
ax.set_title("森林碳储量")
ax.axis("off")
plt.tight_layout()
plt.savefig("carbon_map.png", dpi=200)
| 错误 | 原因 | 解决方案 |
|---|---|---|
ConnectionError | 网络问题 | 检查网络,重试 |
HTTP 429 | 速率限制 | 等待 60 秒后重试 |
ValueError | 无效输入 | 检查参数格式 |
| 空输出 | 无数据 | 尝试不同参数 |
ModuleNotFoundError | 缺少依赖 | 运行 pip install |
基于遥感数据估算森林碳储量,支持 BEF、异速生长方程、IPCC Tier 1/2 三种方法,含蒙特卡洛不确定性分析。
# 单点估算(异速生长)
python scripts\forest-carbon-estimate.py estimate --method allometric --height 15 --forest-type tropical
# 单点估算(BEF)
python scripts\forest-carbon-estimate.py estimate --method bef --agb 200 --forest-type temperate
# IPCC Tier 1 默认值
python scripts\forest-carbon-estimate.py estimate --method ipcc --forest-type boreal --area-ha 100
# 栅格处理
python scripts\forest-carbon-estimate.py estimate --input height.tif --method allometric --output carbon.tif
# 不确定性分析
python scripts\forest-carbon-estimate.py uncertainty --method allometric --height 15 --iterations 5000
# 从 CSV 生成报告
python scripts\forest-carbon-estimate.py report --input carbon_stock.csv
AGB(地上生物量)
↓
BGB = AGB × 根冠比(默认 0.26)
↓
总生物量 = AGB + BGB
↓
碳储量 = 总生物量 × 碳分数(默认 0.47)
| 方法 | 输入 | 说明 |
|---|---|---|
| BEF | AGB (t/ha) | 总生物量 = AGB × BEF |
| 异速生长 | 树高 (m) | AGB = a × H^b |
| IPCC | 森林类型 | IPCC 默认密度 |