如何使用arcpy对DEM栅格数据Nodata进行弥补

  1. 使用 Raster 对象加载 DEM 栅格数据,并使用 GetRasterProperties 函数获取栅格数据的 nodata 值(如果存在)。
  2. import arcpy
    
    # Set input DEM raster and output filled DEM raster paths
    dem_raster = "D:/path/to/input_dem.tif"
    filled_dem_raster = "D:/path/to/filled_dem.tif"
    
    # Load the DEM raster as a Raster object
    dem = arcpy.Raster(dem_raster)
    
    # Get the nodata value of the DEM raster (if exists)
    nodata_value = dem.noDataValue
    

  3. 如果节点数据值存在,则使用 Fill 函数对其进行补充。否则,跳过此步骤。
    import arcpy
    
    # Set input DEM raster and output filled DEM raster paths
    dem_raster = "D:/path/to/input_dem.tif"
    filled_dem_raster = "D:/path/to/filled_dem.tif"
    
    # Load the DEM raster as a Raster object
    dem = arcpy.Raster(dem_raster)
    
    # Get the nodata value of the DEM raster (if exists)
    nodata_value = dem.noDataValue
    
    # If the nodata value exists, fill it with the nearest valid cell value
    if nodata_value is not None:
        filled_dem = arcpy.sa.Fill(dem)
    else:
        filled_dem = dem
    

  4. 最终,在输出路径处保存填充后的 DEM 数据。
    import arcpy
    
    # Set input DEM raster and output filled DEM raster paths
    dem_raster = "D:/path/to/input_dem.tif"
    filled_dem_raster = "D:/path/to/filled_dem.tif"
    
    # Load the DEM raster as a Raster object
    dem = arcpy.Raster(dem_raster)
    
    # Get the nodata value of the DEM raster (if exists)
    nodata_value = dem.noDataValue
    
    # If the nodata value exists, fill it with the nearest valid cell value
    if nodata_value is not None:
        filled_dem = arcpy.sa.Fill(dem)
    else:
        filled_dem = dem
    
    # Save the filled DEM raster to the output path
    filled_dem.save(filled_dem_raster)
    

    请注意,在执行上述操作时,请确保输入和输出栅格数据的路径名和文件类型信息正确,并检查计算机性能和资源使用情况等问题。对于一些复杂或较大的 DEM 数据,可能需要更长时间的计算和显存/内存空间以完成操作。

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

认真学GIS

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值