Setting NoData and Adding Alpha Bands to Remove Black Borders

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2023.2


This article intends to illustrate some of the ways to work with NoData and Alpha bands, with the goal of removing a black border around an image. A combination of setting NoData, setting/adding an Alpha transparency band and/or Clipping are illustrated. The different ways in which NoData and Alpha bands can be set/added and information on the best approach per use case are provided. Note the format chosen for writing also plays a role in whether there is NoData or Alpha. The Quick facts of each format list whether NoData values or Alpha bands are supported.

Note: The data used in this step-by-step tutorial is available in the files section of this article (top right).

Source Data


Step-By-Step Instructions

Option 1: Set NoData

The border value, which is currently black, may be set to NoData using the RasterBandNoDataSetter transformer with a noData value set to 0. This will result in the background becoming transparent. If done this way, there is the possibility that a pixel exists in the imagery (valid data range) that is actually set to 0 for all of the bands (matching the background). Setting 0 to NoData will set cells with this value to transparent, which would generally be undesirable for valid data.

Note that for ‘numeric’ data, it makes more sense to use NoData because it’s likely that you can pick a value that does NOT exist in the imagery.




Option 2: Clip the Black Border

The black border can be removed by creating a clipper feature or by using an existing vector feature to clip away the black border using the Clipper transformer. This works well if there is not going to be any extra processing down the line. If the file is to be manipulated (i.e., reprojected), the result could very well have a black background again, as the issue of transparency still hasn’t been addressed. This method could be used for formats that don’t support Alpha (transparency) or NoData. If reprojection were necessary, it would make sense to reproject first using the CsmapReprojector transformer and base the clipper feature on the reprojected imagery rather than the original, as the bounds will often change.


Option 3: Set the Alpha Band and Clip the Black Border

This method not only clips the black border but also adds an alpha transparency band so that any further processing, like reprojection, doesn’t cause the black border to be introduced again. This is the best method to use if the output format supports Alpha and if the data will be further manipulated in later processing.



Data Attribution

The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - British Columbia.

Was this article helpful?



Please sign in to leave a comment.