Skip to content

Latest commit

 

History

History
91 lines (64 loc) · 2.92 KB

File metadata and controls

91 lines (64 loc) · 2.92 KB

extract-river

Trích xuất đường sông (centerline) từ file DEM, xuất ra shapefile. Có 2 phương pháp:

English

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)

Bắt đầu nhanh

Cách 1: QGIS/GRASS (khuyên dùng)

# 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 100

Kết quả giống hệt chạy GRASS r.watershed + r.to.vect trong QGIS GUI.

Cách 2: WhiteboxTools

# 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ố

Tham số Bắt buộc Mô tả
dem.tif File DEM đầu vào
output.shp File shapefile đầu ra
threshold Không Ngưỡng trích xuất sông (xem bên dưới)

Hướng dẫn threshold

  • 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.

Cài đặt

1. Cài dependencies

Cho QGIS method:

winget install OSGeo.QGIS_LTR

Cho 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.exe

2. Cấu hình đường dẫn (tùy chọn)

Copy 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=100

Nếu không có config.txt, script sẽ tự tìm tool đã cài trên máy.

Credits