RasterCellValueCalculator
From fmepedia
RasterCellValueCalculator is a Workbench Transformer.
| Table of contents |
Description
The RasterCellValueCalculator performs arithmetic operations on two or more rasters using the RasterEvaluationFactory (PR#19500).
Example
This example shows how to use the RasterCellValueCalculator to add or subtract the cell values of two overlapping raster features. This is a form of map overlay function.
Wikipedia defines (http://en.wikipedia.org/wiki/Geographic_information_system) raster overlays like this:
In raster data analysis, the overlay of datasets is accomplished through a process known as ... "map algebra," through a function that combines the values of each raster's matrix. This function may weigh some inputs more than others ... that reflects the influence of various factors upon a geographic phenomenon.
Scenario
In our scenario we take a number of source features representing public utilities such as parks and bus stops. The idea is to identify which areas of the city a person might want to purchase property in.
Each input is weighted by the user to reflect their own personal priorities. The workspace takes all the inputs, and combines them using raster algebra to identify the top-rated areas.
Generally, the user will enter weightings as published parameters like this:

Above: The user chose these weightings....
...and FME will produce output like this:

Above: The user is told that properties in these areas best meet his criteria.
The Workspace
The workspace can be broken down into a number of distinct parts:

1) Data Reading
Unfortunately we don't have this data in a raster format. Because the whole idea is to demonstrate FME's raster algebra, the data needs to be rasterized. So, firstly the workspace:
- Reads a number of source vector datasets.
- Creates a buffer around the source features to create a sphere-of-influence; for example a 1 mile (5280ft) buffer around fire stations.
- Applies a Z value for features, which will work as the weighting for that feature.

Above: The data reading part of the workspace
2) Data Rasterization
Next the workspace can rasterize the data:
- Calculates the maximum and minimum coordinates for all of the source features. (This step is so that we can turn every layer of data into a raster of the same size)
- Rasterizes the data into a numeric raster (UInt8 interpretation because Integers speed up the process over the default Real64 interpretation.)
- The important settings are: ( Fill nodata = no; Group-by = fme_feature_type so we get a separate raster feature per source layer)

Above: The data rasterization part of the workspace
This gives us a raster feature per data type, where each cell within the 'sphere of influence' has a numeric value equivalent to the users chosen weighting, for example:

Above: The rasterized bus stop data might look like this. The user has obviously weighted it 7 out of 10
3) Raster Cell Calculations
Here's where we use the RasterCellValueCalculator.
- First we use a FeatureTypeFilter to separate all the data back into its original layers
- Now we add together the first two layers of data, bus stops and city parks

Above: This part of the workspace looks like this.
In effect the RasterCellValueCalculator is carrying out this action:

Above: Adding two layers of raster data together
- Then we repeat the process adding the result of the first calculation to the raster representing emergency facilities.
- Finally we repeat the process for zoning data. The difference here is that we subtract data.

Above: Here we subtract areas which aren't residential. Values won't go below the minimum of zero.
4) Interpretation Coercion
Now we have a raster dataset containing the information required by the user. All we need to do now is put it into a more presentible format:
- Convert the numeric raster in an RGB colour raster for better visualization
- Identify the maximum value and remove anything else (ie we only want to see the best areas)
- Add an alpha (transparency) band so that we can see a background image through the new data

Above: Here's where we convert the data to a colour image, extract the top values only, and add an alpha band.
5) Read Background Data
Now let's add in some background data to aid our visualization.
- Read in a bunch of MrSID format datasets
- Resample them to a lower resolution (results in a poorer quality, but quicker result)
- Add an alpha (transparency) band to match the main raster feature

Above: Here's where we read in the background data.
6) Mosaic Data and Write Output
The final step is to mosaic the main data onto the background images and write the output. It's necessary to sort the data to make sure the main part appears on top of the background.
- Tag the main data with a sort key of 1 and teh background data with a sort key of 2.
- Sort the data with a Sorter transformer so the background enters the mosaicking process first
- Mosaic the data with a RasterMosaicker transformer.

Above: The final section of workspace
Output
The output is a raster dataset with the results of the process mosaicked onto a set of background images. The exact results will depend on the weighting used by the user.
For example, a weighting of:
Close to a park: 6
Close to a bus stop: 3
Close to a fire station: 4
...looks like this:

Whereas, a weighting of:
Close to a park: 3
Close to a bus stop: 9
Close to a fire station: 6
...looks like this:

