Transition to White

In some raster project specs we may find an item that requires clipping rasters to the project boundary.

User-added image

In FME, it can easily be done with non-rectangular raster clippers, which is implemented as a standard function of the Clipper transformer.
User-added image

But sometimes, the customer's requirements go even further. The rasters shouldn't be clipped abruptly, but rather they should gradually blend into the surrounding whiteness (or blackness).

This is possible using the RasterMosaicker's alpha compositing option. Compositing is an operation that uses the value of the alpha band to weight the amount that each overlapping band contributes to each resultant pixel value.

The idea of how to make a raster gradually disappear is simple - we generate multiple concentric buffers (using the MultiBufferer) around the project area, assign colors changing gradually from black to white, rasterize the features and copy color values to the alpha band where they will represent the amount of transparency rather than colors - higher the value, the more transparent a pixel will be. Areas that were black will be completely transparent, purely white areas will be fully opaque, all shades of gray will be transparent to a different degree.

Here is an image showing how the mask we apply to the raster looks before converting a color band to an alpha band:

User-added image

The RasterExpressionEvaluator allows calculations on band values. In our case, we need to copy values from any color band to the alpha band:

A[0];A[1];A[2];A[0]

The last step is the mosaicking of the original raster and the mask containing transparency information:

User-added image
The attached template contains the workspace, the source raster in TIFF format, and the MapInfo project boundary.