Thursday 20 September 2018

python - Running a Focal Mean or Low Pass Filter or 3 by 3 Mean Kernel in GDAL gdal_calc


I am looking to run the equivalent of Focal Statistics in gdal_calc. Is it possible?


It is a simple focal I require. I need to run a 3 by 3 kernel over the data (mean) and if possible only on NoData (but if on all that is okay as well).


I can do this in other software but specifically asking if a GDAL_calc solution exists.


This is the exact thing I am trying to do on a singular raster


Con(IsNull("C:\temp\SST_Final_C_NoData.tiff"), FocalStatistics("C:\temp\SST_Final_C_NoData.tiff", NbrRectangle(5,5, "CELL"), "MEAN"), "C:\temp\SST_Final_C_NoData.tiff")

GDAL 1.11.0 and Python 3.4.1



Answer



I think I have found it or close enough.



gdal_fillnodata SST_Final_C_NoData.tiff -md 5 -si 2 SST_Final_C_NoData_Foc.tiff

Fills No Data with a 5 pixel window (-md 5) and does 2 passes (-si 2)


No comments:

Post a Comment

arcpy - Changing output name when exporting data driven pages to JPG?

Is there a way to save the output JPG, changing the output file name to the page name, instead of page number? I mean changing the script fo...