Solved

How to associate the value of each cell in a raster mosaic with its proper reader?

  • 26 October 2017
  • 3 replies
  • 2 views

Hello,

I am merging multiple rasters into a single mosaic utilizing the RasterMosaicker. My objective is to find the maximum value across all rasters for each cell and then assign the matching reader for that highest-value cell. I'm having no problem obtaining the max value, however, I'm running into issues when trying to associate that cell with it's proper reader.

I've tried exposing the fme_basename and creating an attribute, but when the mosaic is created, each cell is given the attribute of the first raster (rather than the raster that the highest value is coming from)

Any help would be much appreciated.

Thanks.

icon

Best answer by daveatsafe 27 October 2017, 00:16

View original

3 replies

Badge +22

The issue here is that the fme_basename is an attribute of the raster mosaic feature as a whole, and not the individual cell.

 

 

@takashi could probably whip up a python solution to produce a source matrix, but working just with transformers I would consider experimenting with the following.

 

 

Force all rasters to the same extent and resolution. (If not already)

 

RasterBandCombiner to create a single raster such that raster 1 => band 0, raster 2=>band 1 etc.

RasterExpressionEvaluator to create a band where the pixel value contains the band number that has the highest value

Associate that band number to the fme_basename using the RasterPalette transformers.

Userlevel 2
Badge +17

Hi @jayec

Expanding on the answer from @jdh, I use a RasterExpressionEvaluator to compare a copy of the mosaic raster to the source images, setting the pixel to an index value corresponding to the raster source. The index rasters are mosaicked together to form a single index raster, which output along with the original mosaic, and a CSV of the source filenames and their index values. A string palette output might be better, but I don't know of a format that we can write that to.

I have attached the workspace: calcmosaicsources.fmw

Much thanks to @jdh and @DaveAtSafe for your assistance. I utilized both of your suggestions and it worked out perfectly. A string palette wasn't needed as I essentially linked the CSV to the index raster and from there was able to combine that with the overall mosaic. Thanks again!

Reply