Trích xuất đường sông (centerline) từ file DEM, xuất ra shapefile. Có 2 phương pháp:
| QGIS/GRASS (khuyên dùng) | WhiteboxTools | |
|---|---|---|
| Script | extract_river_qgis.bat |
extract_river_whitebox.bat |
| Thuật toán | MFD (Multi-Flow Direction) | D8 (Single-Flow Direction) |
| Xử lý hố trũng | A* priority-flood | Fill đơn giản |
| Chất lượng | Tốt hơn (mạng lưới đầy đủ hơn) | Tốt (có thể thiếu nhánh nhỏ) |
| Phụ thuộc | Cần cài QGIS | WhiteboxTools + Python rasterio |
| Threshold mặc định | 100 (kích thước lưu vực tối thiểu) | Tự tính (1% max accumulation) |
# Yêu cầu: đã cài QGIS (winget install OSGeo.QGIS_LTR)
extract_river_qgis.bat D:\data\dem.tif D:\data\river.shp
extract_river_qgis.bat D:\data\dem.tif D:\data\river.shp 100Kết quả giống hệt chạy GRASS r.watershed + r.to.vect trong QGIS GUI.
# Yêu cầu: Python 3 + rasterio, WhiteboxTools binary
extract_river_whitebox.bat D:\data\dem.tif D:\data\river.shp
extract_river_whitebox.bat D:\data\dem.tif D:\data\river.shp 500| Tham số | Bắt buộc | Mô tả |
|---|---|---|
dem.tif |
Có | File DEM đầu vào |
output.shp |
Có | File shapefile đầu ra |
threshold |
Không | Ngưỡng trích xuất sông (xem bên dưới) |
- QGIS: kích thước lưu vực tối thiểu (cells). Mặc định: 100
- WhiteboxTools: số cells tích lũy dòng chảy. Mặc định: tự tính (1% max)
Threshold cao → ít sông hơn (chỉ sông chính). Thấp → nhiều nhánh nhỏ hơn.
Cho QGIS method:
winget install OSGeo.QGIS_LTRCho WhiteboxTools method:
pip install rasterio
# Tải WhiteboxTools từ https://www.whiteboxgeo.com/download-whiteboxtools/
# Giải nén sao cho whitebox_tools.exe nằm tại:
# WhiteboxTools_win_amd64/WBT/whitebox_tools.exeCopy config.example.txt thành config.txt rồi sửa đường dẫn:
# Đường dẫn tới qgis_process
QGIS_PROCESS=D:\QGIS 3.44.9\bin\qgis_process-qgis-ltr.bat
# Đường dẫn tới whitebox_tools.exe
WHITEBOX_TOOLS=D:\tools\WhiteboxTools\whitebox_tools.exe
# Threshold mặc định (bị ghi đè bởi tham số dòng lệnh)
# DEFAULT_THRESHOLD=100Nếu không có config.txt, script sẽ tự tìm tool đã cài trên máy.
- GRASS GIS qua QGIS
qgis_process - WhiteboxTools — Prof. John Lindsay (MIT License)
- rasterio — đọc/ghi GeoTIFF