Skip to main content

I need to change the Pixel Values of a raster. The problem is, that I cannot hardcode the new values as I have to work with hundreds of rasters that each have their own mapping table. Is there a way to do this?

Hi @kath, how large is the maximum number of possible colors per a raster? If it's not so large, palette operations might be useful. And I would like to know the schema of the mapping table. Can you post a sample of the table?


Hi Takashi, there will be about 150 values in the mapping table. Per raster there will be 10-20 in use, but technically it might be all 150 values.

The mapping table is generated on the fly using FeatureMerger, having two columns, "LocalValue" and "MasterValue" with integer values from 1 to 256.

I'm trying to use a workaround at th moment: RasterCellCoercer - FeatureMerger (with the mapping table) - FeatureColorSetter - ImagerRasterizer right now. This looks possible to me but takes up loads of time. I would like to stay with the raster if possible.

Thanks for your help!


Hi Takashi, there will be about 150 values in the mapping table. Per raster there will be 10-20 in use, but technically it might be all 150 values.

The mapping table is generated on the fly using FeatureMerger, having two columns, "LocalValue" and "MasterValue" with integer values from 1 to 256.

I'm trying to use a workaround at th moment: RasterCellCoercer - FeatureMerger (with the mapping table) - FeatureColorSetter - ImagerRasterizer right now. This looks possible to me but takes up loads of time. I would like to stay with the raster if possible.

Thanks for your help!

Yes, the RasterCellCoercer does the trick but it's inefficient. I'm unclear the raster interpretation. 3-Band RGB? or 1-Band Gray Scale? How do you map an integer value to a color value (r,g,b)?


The raster is 1 Band Greyscale. (GRAY8)

How do you map an integer value to a color value (r,g,b)?

I didn't figure this bit out yet. If you've got an idea, this would be helpfull.


The raster is 1 Band Greyscale. (GRAY8)

How do you map an integer value to a color value (r,g,b)?

I didn't figure this bit out yet. If you've got an idea, this would be helpfull.

My workaround is running now: I'm just creating an attribute: "MasterValue,MasterValue,MasterValue", feed the FeatureColorSetter with it, and then run the ImageRasterizer.

Even though this does work, it is much too slow for what i'm trying to archieve. So if you know a way to get there without using vector data in between, this would be great.


OK, my intention is: generate GRAY8 palette from the input raster, modify it based on the mapping table, and then apply it to the raster. A palette can be defined by a table consisting of pairs of key value and color value. See the help on the RasterPaletteExtractor transformer to learn more about palette definition.

Probably this workflow works.


OK, my intention is: generate GRAY8 palette from the input raster, modify it based on the mapping table, and then apply it to the raster. A palette can be defined by a table consisting of pairs of key value and color value. See the help on the RasterPaletteExtractor transformer to learn more about palette definition.

Probably this workflow works.

this is the workspace example including a sample data: gray-scale-mapping-example.fmwt (FME 2016.1)


Thanks, takashi, you solved my problem!


Reply