Question

Set ER Mapper ECW writer to have a white background?


Badge +10

Hello all,

I have several hundred geoTiff tiles that I want to mosaic into a single ecw.

How can I set the background of the ecw to white?

Currently the ecw has a full black background, which is a waste of ink when printing.

My workbench is simple; geotiff reader => raster mosaicker => ecw writer


7 replies

Badge +21

Hi @nicholas - this article might help you : https://knowledge.safe.com/articles/58374/how-to-convert-geotiff-to-ecw.html

The trick is to add an alphaband (4). Not sure if your geotiff already has that?

Badge +10

No, the geotiffs have just three bands, RGB

What parameters should I set for the RasterBandAdder?

I'm assuming that the ecw writer will convert the alpha band into whitespace? Because ecw has no alpha layer?

Badge +10

What should the cell value be?

 

What should the Nodata value be?
Badge +10

I am slowly working my way towards what I hope is a solution

Use a RasterExtentsCoercer (extents type: data extents) to generate a polygon around the actual data of the raster. Then a DonutHoleExtractor to throw away the small donut holes (pixels with value 0 which happen to match the NoData value)

This gives me a polygon, which I want to use to set the cell values to white outside of the polygon, and keep the cell values as they are, within the polygon. How do I do this?

Note that I want to write an ecw at the end of this process

Badge +10

I think I have worked it out. But I would appreciate someone checking my work.

geotiff2ecw_working_v2.fmw

The main concept is to generate a polygon that I use to clip the raster, with all the pixels outside the polygon being white, and keeping the pixels inside the polygon at their proper values.

RasterExtentsCoercer (extents type: data extents) to get a polygon boundary of the raster data

DonutHoleExtractor to discard the small donut holes where the pixel is pure black (cell value 0)

Dissolver to fix up some errors in the polygons where donut holes persist

AttributeCreator (@Area())to populate polygon features with area

Sorter (area: Numeric Descending) to sort polygons by area descending

Sampler (First N features) to filter just the first (biggest) polygon.

Badge +10

Continuing on, the largest polygon acts as the Clipper for the raster.

Meanwhile (in parallel) the raster is also modified.

RasterBandNodataRemover to make cell value 0 not the Nodata value

RasterBandNodataSetter (Nodata value: 255) to make the new Nodata value 255

This raster become the Clippee of the Clipper

The output (Inside) of the clipper goes to the ECW writer.

By clipping the raster with the polygon, every cell outside the polygon becomes Nodata. And because Nodata is set to 255, this means that Nodata is rendered white in the ECW writer.

The advantage of this method is that individual pixels inside the raster that are pure black (cell value 0) remain pure black in the output, as they are not classified as Nodata.

Badge +10

geotiff2ecw_working_v3.fmwActually, it is better to use an Aggregator after the Dissolver. This results in a single polygon (an aggregate of several polygons) that become the input to the Clipper. This is a better result (and simpler process)

New workbench attached

Reply