Hi Asher,
One possible way is:
(1) Transform raster cells into points with the RasterCellCoercer.
Output Cell Geometry: Points
Extract Banc Values As: Attributes
(2) Use the Clipper to clip the resulting points by the polygons and migrate polygon ID to the points.
(3) Calculate average of cell values for each polygon ID group with the StatisticsCalculator (Group By: polygon ID).
(4) Merge the result to the original polygon with the FeatureMerger.
Takashi
If the polygons may overlap each other, consider using the SpatialRelator followed by the ListExploder, instead of the Clipper.
You can do it of course without having to coerce the raster.
Make a clourmap of the values, use rasterexpressionevaluator. etc
Takashi, Gio, thanks for your answers.
@Takashi: in step (2), how do you "migrate polygon ID to the points"?
@Gio: what do you mean by making a "colourmap of the values"? My raster is already a single band raster.
Regards,
Asher
Seems I found the answer to the first question :)
Can you please confirm?
Regards
Your data flow has exactly realized my intention.
I meant "merging clipper's attribute to clippees" by "migrate". Sorry for the vagueness.
You can use the Summary features instead of the Complete features, because the statistics calculation has been performed with grouping by UIDN. Although the result will be same, the processing may become faster in this case, I think it's worth to try.
The number of resulting features is less than the number of source polygons. Probably 4 polygons don't have inside points. In other words, the 4 polygons may be outside of the raster. You can check the situation by connecting Inspectors to the source reader feature type and the NotMerged port of the FeatureMerger.
In addition, you can also check the number of features that go to unused output ports if you run the translation with "Run with Full Inspection" command. It's my favorite new functionality in FME 2015.
Thanks to the workflow above I managed to replicate the procedure and compute mean value for raster (NDVI of satellite image) on polygons.
However, I would like to name the computed attribute dynamically (e.g. it should have the same name as the input raster). When AttributeCreator is used to create an attribute named @Value(fme_basename) and value @Value(NDVI_mean) the fme_basename refers to shapefile. How could I get the reference to the raster fme_basename?
If you don't use the fme_basename from the shapefile anywhere, don't expose the fme_basename attribute on the shapefile. This way it will be the basename that is inherited from the supplier that is used in the attribute creator.
Remove the fme_basename from the features originating from the shapefile source.
If you don't use the fme_basename from the shapefile anywhere, don't expose the fme_basename attribute on the shapefile. This way it will be the basename that is inherited from the supplier that is used in the attribute creator.
Figured out that RasterCellCoercer Preserve Attributes was set to No. And therefore the raster fme_basename did not apear later in the workbench.