Skip to main content
Solved

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

  • October 26, 2017
  • 3 replies
  • 40 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.

Best answer by daveatsafe

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

This post is closed to further activity.
It may be an old question, an answered question, an implemented idea, or a notification-only post.
Please check post dates before relying on any information in a question or answer.
For follow-up or related questions, please post a new question or idea.
If there is a genuine update to be made, please contact us and request that the post is reopened.

3 replies

jdh
Contributor
Forum|alt.badge.img+37
  • Contributor
  • 2002 replies
  • October 26, 2017

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.


daveatsafe
Safer
Forum|alt.badge.img+19
  • Safer
  • 1637 replies
  • Best Answer
  • October 26, 2017

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


  • Author
  • 1 reply
  • October 27, 2017
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!