Skip to main content

I'm new to FME, so if there's a better option it would be greatly appreciated: I have multiple geotiffs (georeferenced black and white aerial phtographs) that I want to convert to a single ECW for use in Geoserver. As there were issues with black and white I set the cut off edges (which contained labels e.g.) in MS Paint before georeferencing in QGIS to RGB red (as these could be manually set to nodata in QGIS).

So the corresponding geotiffs have all band 0 (red8) value 237 / Band 1 (green8) value 28 / Band 2 (blue8) value 36 (and a band3 alpha8 255) for the nodata values. I'd like to have this RGB value 237, 28, 36 set to be interpreted as extra nodata value or set to be replaced by value 0 and add this (with the other value 0 for nodata for the normal background, as the geotiffs are not fully upright) to the ECW as nodata.

I tried rasterPaletteExtractor but it rejected the geotiff. Or should they all be extracted by band first (bandselector) or should it be done in some way with the rasterExpressionEvaluator?

So FME treats noData values on bands independently. So if you set band 0 NoData to 237, it would identify all pixels with a value of 237, not just 237/28/36.

 

 

My recommendation is to use a RasterBandNoDataRemover followed by a RasterExpressionEvaluator with the following expressions

if(A(0]==237 && A 1] ==28 && A 2] ==36, 0, A 0])

if(A(0]==237 && A 1] ==28 && A 2] ==36, 0, A 1])

if(A(0]==237 && A 1] ==28 && A 2] ==36, 0, A 2])

 

 

and then a RasterBandNoDataSetter (0).

 

 

This will change 237/28/36 only to 0.

 

 

Note that weird things happen in the RaterExpressionEvaluator if there is nodata values on the bands, which is why you remove it first.

 

 

You can change the conditional to include the alpha band as well, I wasn't sure if that was an and/or condition)

The expression is: if (conditions, pass value, fail value)

 

so if the condition is met set it to 0, otherwise keep the same value.

Hi @arsi, if you need to replace cell values of original Nodata for all bands with 0, the RasterBandNodataSetter with setting Yes to the Replace Cell Values parameter should work as well. You can also select the bands to be modified explicitly with a preceding RasterSelector, if necessary.

 


Hi @arsi, if you need to replace cell values of original Nodata for all bands with 0, the RasterBandNodataSetter with setting Yes to the Replace Cell Values parameter should work as well. You can also select the bands to be modified explicitly with a preceding RasterSelector, if necessary.

 

Oh, I have misunderstood the requirement. If the original Nodata definition was R=237 AND G=28 AND B=36, the workflow above won't help you. Follow @jdh's suggestion.


Thanks a lot! I added a rasterinterpretationcoercer to put the nodata to a new alpha band.

However, it seems that the compression when writing to ECW also generates footprints in the nodata in the alphaband (value becomes 1 or more). It seems that Geoserver has no option to declare the entire alpha band to be nodata regardless of value after compression (like QGIS has).

Is it possible to let the entire alpha band retain it's value 0 for nodata when writing to ECW? Or is there another way? Can for instance the entire geotiff be used as a clipper in a second FME-script or all values of the alphaband of the ECW be reset to 0 and are they then retained when writing to ECW again or are they again lost in compression?


Reply