QGIS は欠落している DEM データを補います

以下は、QGIS を使用して、低精度の DEM データを使用して欠落している DEM データを高精度で埋めるコードを作成する例です。


# qgis.core から必要なライブラリをインポートします
import QgsProject, QgsRasterLayer
from qgis.analysis import QgsFillMissingValues

# 入力パスと出力パスを定義します
low_res_path = 'path_to_low_resolution_dem.tif' # 低精度 DEM データ パス
high_res_path = 'path_to_high_resolution_dem.tif' # 高精度 DEM データ パス
Output_path = 'path_to_output_raster_file.tif' # 埋め込まれた出力 DEM データ パス

# ラスター レイヤー (低解像度) を読み込みます
low_res_layer = QgsRasterLayer(low_res_path, "低解像度 DEM")
if not low_res_layer.isValid():
    print("低解像度 DEM レイヤーを読み込めません!")
    exit()

# ラスター レイヤー (高解像度) を読み込みます
high_res_layer = QgsRasterLayer(high_res_path, "高解像度 DEM")
if not high_res_layer.isValid():
    print("高解像度 DEM レイヤーを読み込めません!")
    exit()

# 塗りつぶしアルゴリズム オブジェクトを作成します
fill_algorithm = QgsFillMissingValues()
fill_algorithm.setInput(low_res_layer)
fill_algorithm.setSourceLayer(high_res_layer)

# 充填操作を実行し、結果を保存します
result = fill_algorithm.process(output_path)
if result:
    print("DEM データの充填が完了しました!")
else:
    print("充填プロセス中にエラーが発生しました!")
 

「path_to_low_resolution_dem.tif」を低解像度 DEM データ ファイルへのパスに置き換え、「path_to_high_resolution_dem.tif」を高解像度 DEM データ ファイルへのパスに置き換え、「path_to_output_raster_file.tif」を保存したいパスに置き換えてください。の結果ファイルのパス。このコードを実行すると、低精度の DEM データを使用して高精度の欠落データが埋められ、結果が指定された出力パスに保存されます。

おすすめ

転載: blog.csdn.net/weixin_58851039/article/details/131448741