360 Secure SkillHub
360 安全技能中心

geoskill-lulc-change-matrix

读取两期整数类别土地覆被分类 GeoTIFF(或离线合成数据),逐像元交叉制表,输出转移矩阵 CSV、逐类毛损失/毛增益/净变化与面积统计 JSON、Sankey 流向 nodes+links、变化图 GeoTIFF 及运行清单,可结合 bbox 将像元数换算为平方公里。

ruiduobao
ruiduobao
热度 13.45
最近更新 2026-08-04 20:54:22
分类:数据依赖:代码执行 / 读写文件应用场景:数据处理 / 报告撰写

安装技能

复制下面的话术发给你的 Agent,它会通过 secure-skills 检索并安装该技能。

执行命令安装此 skill: npx secure-skills-cli add geoskill-lulc-change-matrix
Metadata
name
geoskill-lulc-change-matrix
description
两期土地覆被分类栅格逐像元交叉制表,输出转移矩阵、变化面积统计与 Sankey 流向数据

土地覆被转移矩阵 | Land Cover Transition Matrix

Perform pixel-by-pixel cross-tabulation of two land cover classification rasters (integer classes) to quantify transitions between classes. Outputs a transition matrix (rows = earlier epoch t1, columns = later epoch t2, cell values = pixel counts), per-class gross loss / gross gain / net change and area statistics, as well as nodes + links data ready to be used directly in a Sankey flow diagram.

Typical applications: cropland loss / built-up expansion monitoring, land use transition analysis, and national land change ledgers. Diagonal cells are unchanged pixels, while off-diagonal cells are pixels that have transitioned; combined with the bbox, pixel counts can be converted to square kilometers. Synthetic mode injects a known number of class transitions (e.g., cropland → built_up) so that "detected change = injected change" can be verified offline.

Dependencies / 依赖

pip install 'numpy' 'rasterio' 'pandas'

Usage / 使用方法

Basic Usage

python geoskill-lulc-change-matrix.py --bbox 116.0 39.0 117.0 40.0 --n-classes 5

Example 1 (synthetic data, offline)

python geoskill-lulc-change-matrix.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

Example 2 (read two local classification rasters)

python geoskill-lulc-change-matrix.py --t1 cls_2015.tif --t2 cls_2020.tif --output-dir ./out

Example 3 (different area + quiet mode)

python geoskill-lulc-change-matrix.py --bbox 121.0 31.0 122.0 32.0 --synthetic --quiet --output-dir ./out

Example 4 (3-class scenario)

python geoskill-lulc-change-matrix.py --bbox 116 39 117 40 --synthetic --n-classes 3 --output-dir ./out

Output / 输出

File Format Description
transition_matrix.csv CSV Transition matrix (with row and column totals)
change_areas.json JSON Per-class gross loss/gain/net change + area in km²
sankey.json JSON Sankey flow nodes + links
change_map.tif GeoTIFF (int32) Change map (0 = unchanged, 1 = changed)
output-manifest.json JSON Run manifest

Data Source / 数据源 / Source

  • Two local classification GeoTIFFs (integer classes, spatially aligned);
  • --synthetic generates a two-epoch classification pair offline (no network, no account required).

Privacy / 隐私声明 / Privacy

  • Runs offline by default; --synthetic mode requires no network at all.
  • All processing is performed locally; no user data is uploaded.

License / License

MIT



name: geoskill-lulc-change-matrix description: '两期土地覆被分类栅格逐像元交叉制表,输出转移矩阵、变化面积统计与 Sankey 流向数据'

土地覆被转移矩阵 | Land Cover Transition Matrix

对两期土地覆被分类栅格(整数类别)做逐像元交叉制表,量化类别之间的 转移关系。输出转移矩阵(行=前期 t1,列=后期 t2,元素为像元数)、 逐类毛损失/毛增益/净变化与面积统计,以及可直接用于 Sankey 流向图的 nodes + links 数据。

典型应用:耕地流失/建设用地扩张监测、土地利用转型分析、国土变化台账。 对角线为未变化像元,非对角线即发生转移的像元;结合 bbox 可把像元数 换算为平方公里。合成模式会注入确定数量的类别转移(如 cropland → built_up), 便于离线验证「检测到的变化量 = 注入量」。

依赖

pip install 'numpy' 'rasterio' 'pandas'

使用方法

基本用法

python geoskill-lulc-change-matrix.py --bbox 116.0 39.0 117.0 40.0 --n-classes 5

示例 1(合成数据,离线)

python geoskill-lulc-change-matrix.py --bbox 116.0 39.0 117.0 40.0 --synthetic --output-dir ./out

示例 2(读取两期本地分类栅格)

python geoskill-lulc-change-matrix.py --t1 cls_2015.tif --t2 cls_2020.tif --output-dir ./out

示例 3(不同区域 + 静默)

python geoskill-lulc-change-matrix.py --bbox 121.0 31.0 122.0 32.0 --synthetic --quiet --output-dir ./out

示例 4(3 类场景)

python geoskill-lulc-change-matrix.py --bbox 116 39 117 40 --synthetic --n-classes 3 --output-dir ./out

输出

文件 格式 说明
transition_matrix.csv CSV 转移矩阵(含行列合计)
change_areas.json JSON 逐类毛损失/增益/净变化 + 面积 km²
sankey.json JSON Sankey 流向 nodes + links
change_map.tif GeoTIFF (int32) 变化图(0=未变,1=变化)
output-manifest.json JSON 运行清单

数据源 / Source

  • 本地两期分类 GeoTIFF(整数类别,空间对齐);
  • --synthetic 离线合成两期分类对(无需网络、无需账号)。

隐私声明 / Privacy

  • 默认离线运行,--synthetic 模式完全无网络。
  • 所有处理在本地完成,不上传用户数据。

License

MIT