span8
span4
span8
span4
The intention of this article is 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 NoData or Alpha.The Quick facts of each format lists whether NoData values or Alpha bands are supported.
RemoveBlackBorders.fmwt (completed template workspace with all three options)
BlackBorderData.zip (starting GeoTIFF data with the black border)
Original GeoTIFF file with the black border
The border value,which is currently black,may be set to NoData using theRasterBandNoDataSettertransformer 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.
Original file with NO NoData set = black pixel in image (ie: all 3 bands are set to 0)
NoData IS set to 0 = The pixel (0,0,0) becomes transparent when it should be a valid pixel
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 theClippertransformer.This works well if there is not going to be any extra processing done down the line.If the file is to be manipulated (ie: 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 will be necessary it would make sense to reproject first using theCsmapReprojectortransformer and base the clipper feature on the reprojected imagery rather than the original,as the bounds will often change.
Raster clipped to remove black border
Raster clipped to remove black border,but then reprojected,the black border appears within the clipped bounds
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.
Clipped and Alpha band added,black border doesn't return after being reprojected
Data Attribution
The data used here originates from open data made available by theCity of Vancouver,British Columbia.It contains information licensed under the Open Government License - Vancouver.
Tiling Raster Data with the RasterTiler
Alpha Compositing: Blending Two Raster Images
Raster to Raster Translation (Geotiff to JPEG) with Reprojection
Raster Mask and LOD (Level of Detail) for KML Output
Viewing and Inspecting Rasters
How To Optimize Your Raster Data Using the RasterInterpretationCoercer
Combining Rasters with the RasterExpressionEvaluator
© 2019 亚搏在线Safe Software Inc |Legal