Quantcast
Channel: Active questions tagged raster-calculator - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 191

Filling NoData values in raster with another raster's values in ArcGIS Pro using con(isnull())

$
0
0

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:

  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?


Viewing all articles
Browse latest Browse all 191

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>