1

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 = True
cloud_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:

  1. The NoData value settings for cloud_masked
  2. 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?

3
  • Are you just missing statistics on the resulting raster?
    – Vince
    Commented Aug 5 at 11:05
  • 1
    Just me thinking out aloud, the fact you have deliberately named your input raster original_STACK.tif suggests to me that this a multi-band raster, i.e. a stack of bands. Not sure if CON() applies your logic to each band within the raster stack, you will need to check that. My experience with CON() is typically on a 1-band raster such as a DEM.
    – Hornbydd
    Commented Aug 5 at 12:14
  • Yes, most Spatial Analyst functions operate on a single band only. If you pass a multiband raster, by default the first band is used. If "original_stack.tif has multiple bands, you need to apply the Con(IsNull()) functions to each band separately and then composite the output bands.
    – user2856
    Commented Aug 6 at 3:17

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.