最新上线付费视频教程,包含 GRASS+Windows 平台下 r.slopeunits 的移植、斜坡单元分割操作实录以及关键点讲解,有需要的同学可点击这里

该插件由意大利@Massimiliano 基于 GRASS 平台开发,用于快速划分斜坡单元。

原作者只适配了 Ubuntu 系统,而未适配 windows,而本人尝试使用后发现并不好使,故想办法移植到 Windows 下使用。

由于花费了不少心思摸索,故记录,方便下次查阅&分享。

快速开始

QGIS 安装

  • 确保自己安装了最新版本的 QGIS,GRASS 会一同被安装。
  • 安装完成后,检查目录下是否有 GRASS 程序,程序应位于 QGIS/APP 目录下,例如:D:\Program Files\QGIS 3.22.4\apps\grass\grass78\

安装 r.slopeunits

官方网站

  • 在官方网站下载slu_grass78.tgz,并从中提取r.slopeunits文件,重命名为r.slopeunits.py
  • 得到r.slopeunits.py文件后,复制到D:\Program Files\QGIS 3.22.4\apps\grass\grass78\scripts路径(根据自己的安装目录修改)下。

Windows 适配

D:\Program Files\QGIS 3.22.4\apps\grass\grass78\bin目录下,创建r.slopeunits.bat文件,内容如下:

1
@"%GRASS_PYTHON%" "%GISBASE%/scripts/r.slopeunits.py" %*

试运行

运行 GRASS GIS 即可,在 GUI 下即可调用 r.slopeunits 进行斜坡单元分割。

试运行效果

GRASS 中,调用命令之前记得先调用 r.region 设置边界,否则可能输出结果为空,详情见r.region - GRASS GIS manual (osgeo.org)

插件详细的参数含义可根据r.slopeunits —help的内容查看,并进行调整,内容如下:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
r.slopeunits --help
Create a raster layer of slope units
Usage:
r.slopeunits.py [-mn] demmap=name [plainsmap=name] slumap=name [slumapclean=name] [circvarmap=name] [areamap=name] thresh=value areamin=value [areamax=value] cvmin=value rf=value maxiteration=value [cleansize=value] [--overwrite] [--help] [--verbose] [--quiet] [--ui]
Flags:
-m Perform quick cleaning of small-sized areas and stripes
-n Perform detailed cleaning of small-sized areas (slow)
Parameters:
demmap Input digital elevation model
plainsmap Input raster map of alluvial_plains
slumap Output Slope Units layer (the main output)
slumapclean Output Slope Units layer (the main output)
circvarmap Output Circular Variance layer
areamap Output Area layer; values in square meters
thresh Initial threshold (m^2).
areamin Minimum area (m^2) below whitch the slope unit is not further segmented
areamax Maximum area (m^2) above which the slope unit is segmented irrespective of aspect
cvmin Minimum value of the circular variance (0.0-1.0) below whitch the slope unit is not further
segmented
rf Factor used to iterativelly reduce initial threshold: newthresh=thresh-thresh/reductionfactor
maxiteration maximum number of iteration to do before the procedure is in any case stopped
cleansize Slope Units size to be removed

GUI 操作

r.slopeunits的作者非常贴心,还给设计了 UI 界面来实现无代码操作,直接在控制台输入r.slopeunits —ui即可调用。

GUI界面-r.slopeunits

分割效果

采用 r.slopeunits 成功分割得到的结果为栅格格式输出,每个类别有一个 ID,渲染效果如下:

r.slopeunits的分割效果

Q&A

近期不少同学发邮件私信我各类疑难杂症,在此总结回复。

  • 可供参考的命令行?

本文使用的命令行参数如下,供参考:

1
r.slopeunits demmap=DEM_FILL@PERMANENT slumapclean=SluMapC@PERMANENT slumap=SluMap@PERMANENT thresh=50000 areamin=2000 cvmin=0.25 rf=10 maxiteration=5 --overwrite
  • 命令行已经可以调用r.slopeunits,但是输出结果是空白?

请检查g.region是否提前调用,要设置成DEM一样的范围;另外,多试一些参数,调参,可能是参数不正确,具体参考原论文的参数。

1
g.region raster=DEM_FILL@PERMANENT
  • 执行报错?

检查一下DEM 的坐标系是否为WGS 84/UTM坐标系,使用g.region -p查看当前的参数信息是否正确。

正常进行一个县级行政区 30 米精度的分割耗时在 5 分钟以内,可作为参考。

一般采用 30 米或 12.5 米精度的数字高程(DEM)作为源数据进行分割,DEM 下载可看博主此前文章

以下是正常执行时的运行日志,供参考:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
(Tue Jan 16 17:27:34 2024)
r.slopeunits demmap=DEM@PERMANENT slumapclean=SluMapC@PERMANENT slumap=SluMap@PERMANENT thresh=50000 areamin=2000 cvmin=0.25 rf=10 maxiteration=5 --overwrite
Initial threshold (cells) is : 58
Initial minimum area (cells) is : 2
WARNING: MASK already exists and will be overwritten
Univar: 1199471
Threshold (hectars) is: 4.4089525877448645
No. of cells to be still classified as SLU is: 312522. Loop done: 1
Univar: 21531
Threshold (hectars) is: 3.9002272891589187
No. of cells to be still classified as SLU is: 290991. Loop done: 2
Univar: 20984
Threshold (hectars) is: 3.4762895403372966
No. of cells to be still classified as SLU is: 270007. Loop done: 3
Univar: 19656
Threshold (hectars) is: 3.052351791515675
No. of cells to be still classified as SLU is: 250351. Loop done: 4
Univar: 20405
Threshold (hectars) is: 2.7132015924583777
No. of cells to be still classified as SLU is: 229946. Loop done: 5
Removing temporary files
(Tue Jan 16 17:29:25 2024) Command finished (1 min 51 sec)
  • r.slopeunits参数选取 or 使用问题

如果已经可以调用r.slopeunits —help,说明移植已经成功,本教程目的已经达到;剩下的就是调参和各类 GRASS 软件的使用问题,不在本文章讨论范围;此类问题可以在评论区提问(博主会收到邮件通知),但请尽量不要发送邮件私信,感谢。

  • 私信&咨询&求助?

由于处于关键人生阶段(撰写毕业论文 ing…),时间有限,博主暂无法一一回复各类疑难杂症。

  • 视频教程?

应各位同学要求,录制了全操作流程的视频教程,付费授权观看,详见:付费视频教程

其它

使用该插件的同学应该都是做滑坡易发性评价相关的研究,如果此文帮到了你,方便的话可以引用以下论文,感谢!

  • Xia, D., Tang, H., Glade, T., Tang, C., & Wang, Q. (2024). KNN-GCN: A Deep Learning Approach for Slope-Unit-Based Landslide Susceptibility Mapping Incorporating Spatial Correlations. Mathematical Geosciences. https://doi.org/10.1007/s11004-023-10132-3
  • Xia, D., Tang, H., Sun, S., Tang, C., & Zhang, B. (2022). Landslide Susceptibility Mapping Based on the Germinal Center Optimization Algorithm and Support Vector Classification. Remote Sensing, 14(11), 2707. https://doi.org/10.3390/rs14112707
KNN-GCN: A Deep Learning Approach for Slope-Unit-Based Landslide Susceptibility Mapping Incorporating Spatial Correlations - Mathematical Geosciences
Landslides pose a significant risk to human life and property, making landslide susceptibility mapping (LSM) a crucial component of landslide risk assessment. However, spatial correlations among mapping units are often neglected in statistical or machine learning models proposed for LSM. This study proposes KNN-GCN, a deep learning model for slope-unit-based LSM based on a graph convolutional network (GCN) and the K-nearest neighbor (KNN) algorithm. The model was experimentally applied to the Lueyang region and validated through the following steps. Firstly, we collected data for 15 landslide causal factors and from landslide inventories and established a slope unit map (SUM) through slope unit division. Next, we performed a multicollinearity analysis of landslide causal factors and divided the training and test sets at a 7:3 ratio. We then constructed a GCN model based on a slope unit graph (SUG) generated from the SUM using the KNN algorithm. The proposed KNN-GCN model was tuned using a grid search with fivefold cross-validation on the training set, and then trained and validated on training and test sets separately. Finally, the performance of the KNN-GCN model was compared with that of six other models which were categorized into two groups: CG#1 was the traditional KNN, support vector regression (SVC), and automated machine learning (AutoML), and CG#2 included KNN-G, SVC-G and AutoML-G with additional spatial information. Our results demonstrate that the proposed model achieves superior performance (area under the curve [AUC] = 0.8351) and generates the most comprehensible susceptibility map with distinct boundaries between different susceptibility levels. Notably, while the proposed KNN-GCN model displays exceptional performance in slope-unit-based LSM, its implementation requires high-level computing resources, and it is not recommended for small datasets.
https://link.springer.com/article/10.1007/s11004-023-10132-3
Landslide Susceptibility Mapping Based on the Germinal Center Optimization Algorithm and Support Vector Classification
A landslide susceptibility model based on a metaheuristic optimization algorithm (germinal center optimization (GCO)) and support vector classification (SVC) is proposed and applied to landslide susceptibility mapping in the Three Gorges Reservoir area in this paper. The proposed GCO-SVC model was constructed via the following steps: First, data on 11 influencing factors and 292 landslide polygons were collected to establish the spatial database. Then, after the influencing factors were subjected to multicollinearity analysis, the data were randomly divided into training and testing sets at a ratio of 7:3. Next, the SVC model with 5-fold cross-validation was optimized by hyperparameter space search using GCO to obtain the optimal hyperparameters, and then the best model was constructed based on the optimal hyperparameters and training set. Finally, the best model acquired by GCO-SVC was applied for landslide susceptibility mapping (LSM), and its performance was compared with that of 6 popular models. The proposed GCO-SVC model achieved better performance (0.9425) than the genetic algorithm support vector classification (GA-SVC; 0.9371), grid search optimized support vector classification (GRID-SVC; 0.9198), random forest (RF; 0.9085), artificial neural network (ANN; 0.9075), K-nearest neighbor (KNN; 0.8976), and decision tree (DT; 0.8914) models in terms of the area under the receiver operating characteristic curve (AUC), and the trends of the other metrics were consistent with that of the AUC. Therefore, the proposed GCO-SVC model has some advantages in LSM and may be worth promoting for wide use.
https://www.mdpi.com/2072-4292/14/11/2707