I am trying to write a code on the python console on ArcGIS pro to iterate through TIFF files on my folder and fill the gaps. However, I tried lots of things and all seem to have a problem. I run into the error using Focal Function.
Currently I've been using these parameters:
# Set focal statistics parameters
neighborhood = arcpy.sa.NbrRectangle(6500, 6500, "CELL")
statistics_type = "MEAN"
# Loop through raster files in input directory
for file_name in os.listdir(input_dir):
if file_name.endswith(".tif"): # Process only TIFF files
# Set input and output paths
input_path = os.path.join(input_dir, file_name)
output_path = os.path.join(output_dir, file_name)
# Perform raster calculation
print(f"Processing {file_name}...")
in_conditional_raster = arcpy.sa.IsNull(input_path)
out_conditional_raster = arcpy.sa.Con(in_conditional_raster,
arcpy.sa.FocalStatistics(input_path, neighborhood, statistics_type),
input_path)
out_conditional_raster.save(output_path)
And this is the error I've been getting:
RuntimeError: Failed to apply Raster Function: 'Focal' (The parameter is incorrect.
Parameter 'Width' is missing or invalid. Bind failed in function 'Focal Function' [].)
If anyone can help, I would appreciate it!
Code formatting ... the Community Version - Esri Community
formatting will provide line numbers
Focal Statistics (Spatial Analyst)—ArcGIS Pro | Documentation
width and height are in the number of cells not in planar units if that is what 6500 represents