Skip to main content
When Clipping (keeping Inside) a RGB raster with an irregular vector polygon and writing to TIFF, outside the clipped area is black. How do you change this to white? It seems such a simple thing but unless I'm missing something not simple to achive.

 

 

 

OK so it was simple!

 

 

Adding a RasterBandNodataSetter with a value of 255 BEFORE the Clipper seems to do the trick.
Hi Mark

 

You'll want to be sure, however, that you don't have any data with values of 255 as well. Otherwise you could end up with little spots of 'nodata' all over the dataset.

 

 

I guess that might not matter depending on what format you write to (does it support "nodata"), and what application you're using the data in (how does it render "nodata" - for example the FME Data Inspector renders it invisibly, others might just show it as white).

 

 

Since you're writing to TIFF, which does support the concept of nodata, you'll need to be careful.

 

 

So I did a bit of experimenting because nodata has always confused me.

 

 

Ideally you'd set the value to something you know you DON'T have in your data. For example, if you know no cells have a value of 200, then use that. Then, after the Clipper, use a RasterCellValueReplacer to convert values of 200 to 255.

 

 

That way the original outside of the clip will be white (255) but you won't end up tagging other cells with 255 as nodata.

 

 

Of course, if you know no cells have a value of 255 in the first place, then it doesn't matter.

 

 

Hope this helps - and isn't too confusing!

 

 

Regards

 

 

Mark

 

 

Mark Ireland

 

Product Evangelist

 

Safe Software Inc
For example, see this image. I set the Nodata value to 255 and clipped the data. It worked great for outside the clip boundary (red arrow) - unfortunately big parts of my raster already had 255 and now they are invisible (blue arrow)!

 

 


This is an issue I have faced several times and I find it complicated. The only way I know how to solve this problem is to convert the image to a higher bit rate raster ( so that there values above 255), asign the no data to a white colour outside the known range of the data and then write it out as a 16 bit image. However, I have found that this can cause all sorts of issues depending on what writer format is being used, whether the image has a pallette, and whether you intend to mosaic the image (16 bit and 8bit can not be stiched together).

 

 

I also think FME needs to improve on how it deals with making wholesale changes to multi band rasters. It seems quite complicated in FME 2013-2014. I think some more options within the raster writers to change bit rate, no data values and other important factors would negate having to use lots of transformers and a complex workspace.
Thanks! worked like a charm!

Reply