I am currently working with two rasters in ArcGIS Pro: a masked raster (cloud_masked) where clouds and shadows have been removed, resulting in NoData values (holes), and an unmasked stacking raster (original_stack). Both rasters have the same size and resolution. I want to fill the NoData values in the cloud_masked raster with the corresponding values from the original_stack raster.
Here is what I have tried so far:Using Raster Calculator with the Con Function
Con(IsNull("cloud_masked"), "original_stack", "cloud_masked")
When I used this method, the resulting raster turned out black instead of filling the NoData values correctly.
import arcpy from arcpy.sa import *arcpy.env.workspace = "C:/path_to_workspace"arcpy.env.overwriteOutput = Truecloud_masked_path = "C:/path_to_workspace/cloud_masked.tif"original_stack_path = "C:/path_to_workspace/original_stack.tif"output_raster_path = "C:/path_to_workspace/filled_cloud_masked.tif"cloud_masked_raster = Raster(cloud_masked_path)original_stack_raster = Raster(original_stack_path)filled_raster = Con(IsNull(cloud_masked_raster), original_stack_raster, cloud_masked_raster)filled_raster.save(output_raster_path)print(f"Filled raster saved to {output_raster_path}")
Things I have checked:
- The NoData value settings for cloud_masked
- Ensuring both rasters have matching data types
How can I properly fill the NoData values without the resulting raster turning black?
Additionally, is there a better approach to handle the NoData values correctly?