Solved

Fill raster NULL by average value of surrounding pixels?

  • 31 January 2023
  • 1 reply
  • 53 views

Badge +14
  • Contributor
  • 120 replies

I have a raster DTM with some erroneous transparent areas. I would like to fill these using average vales of the surrounding pixels, to keep everything nice and smooth. GRASS has the 'fill nulls' function that does this, does FME have anything similar?

icon

Best answer by daveatsafe 1 February 2023, 00:08

View original

1 reply

Userlevel 2
Badge +17

Hi @aron​,

For small holes (less than 10 pixels wide), you can use the RasterConvolver on a copy of the raster to smooth the pixel values and fill in the null areas. Next, use the RasterMosaicker to fill the holes in the original raster from the smoothed one, by laying the original raster on top of the smoothed one.

Screen Shot 2023-01-31 at 2.58.55 PMThe smoothing will require custom matrix in the RasterConvolver:

Screen Shot 2023-01-31 at 2.47.54 PMPick a size to cover the largest expected hole (11x11 max), then set just the outside edge values to 1 and all the inner values to 0. This will ensure the valid outer values replace the null values in the center.

The Sorter ensures that the original image is added to the mosaic last, so only the null values will be carried over from the smoothed raster.

If you expect to see holes larger than 9 pixels, there is more complex method that can be used to fill them.

Reply