- 使用 Raster 对象加载 DEM 栅格数据,并使用 GetRasterProperties 函数获取栅格数据的 nodata 值(如果存在)。
-
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
- 如果节点数据值存在,则使用 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
- 最终,在输出路径处保存填充后的 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 数据,可能需要更长时间的计算和显存/内存空间以完成操作。
如何使用arcpy对DEM栅格数据Nodata进行弥补
最新推荐文章于 2024-09-30 16:39:06 发布