Raster Pyramiding Example

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2023.2

Introduction

This article intends to illustrate how to take a raster (using a Canadian Digital Elevation Data (CDED) raster), resample the raster into various sized layers from smallest to largest with the RasterPyramider transformer, use the ExpressionEvaluator transformer to determine how many tiles needed to be created based on the layers created with the RasterPyramider transformer, tile the layers with the RasterTiler transformer calculated by the ExpressionEvaluator transformer, use the StringConcatenator transformer to construct the tiles output name, then output the raster tiles to GeoTIFF format.

Note: The data used in this step-by-step tutorial is available in the files section of this article (top right).
 

Source Data

start-raster.png
 

Step-By-Step Instructions

1. Read in the Digital Elevation Model (DEM)

In a blank workspace, add a Canadian Digital Elevation Data (CDED) reader to the canvas and browse to the Interopolis-250K.dem. Click OK to add it to the canvas.

cded-reader.png
 

2. Add the RasterPyramider Transformer

Add a RasterPyramider transformer to the workspace and connect the CDED Reader to it. Set both the Number of Columns (cells) in Smallest Level and Number of Rows (cells) in Smallest Level parameters to 24. The rest of the parameters can be left as is. The first raster to be created will be resampled to be 24x24 pixels in size. Each subsequent raster will be twice the resolution, giving 48x48, etc. When the size of the original raster is reached, then the pyramiding process stops. The original raster size is 1201 x 1201 pixels. The smallest raster will be 24 x 24.

rasterpyramider-transformer.png

Therefore, the raster pyramids will be:

24 x 24
48 x 48
96 x 96
192 x 192
384 x 384
768 x 768
1536 x 1536


giving a total of seven pyramid layers.

rasterpyramider-transformer-output.png

 

3. Add the ExpressionEvaluator Transformer

Add an ExpressionEvaluator transformer to the workspace and connect the Pyramids output port to the RasterPyramider transformer. Open the ExpressionEvaluator transformer parameters dialog, and under Output Attribute Name, type numTiles in the Result parameter. Next, in the Arithmetic Expression parameter textbox, add parentheses; in the parentheses, select the FME Feature Attributes category drop-down and select what is shown in the image below. This simple formula is used to determine how many tiles to create for each pyramid layer.

(@Value(_num_pyramid_levels)-@Value(_pyramid_level))

 

expressionevaluator-transformer.png

 

4. Add the RasterTiler Transformer

Add a RasterTiler transformer to the workspace and connect the ExpressionEvaluator transformer output port to it. Open the RasterTiler transformer parameters dialog and under Number of Tiles, set both the Columns and Rows parameters to numTiles using the drop-down arrow beside them and under the Attribute Value category. This will tile the rasters.

rastertiler-transformer.png


5. Add the StringConcatenator Transformer
Add a StringConcatenator transformer to the workspace and connect the RasterTiler transformer Tiles port to it. Open the StringConcatenator transformer parameters dialog and under Output Result, set the New Attribute parameter textbox to RasterTilerName. Then, under String Parts, enter the following:

String Type String Value
Constant Level
Attribute Value _pyramid_level
Constant -Row
Attribute Value _tile_row
Constant -Col
Attribute Value _tile_column

The Concatenated Results should look like this:

Level@Value(_pyramid_level)-Row@Value(_tile_row)-Col@Value(_tile_column)


The result from the value results in:

7 - Layer 6 = 1 (i.e. 1x1 tiles)
7 - Layer 5 = 2 (i.e. 2x2 tiles)
7 - Layer 4 = 3 (i.e. 3x3 tiles)
7 - Layer 3 = 4 (i.e. 4x4 tiles)
7 - Layer 2 = 5 (i.e. 5x5 tiles)
7 - Layer 1 = 6 (i.e. 6x6 tiles)
7 - Layer 0 = 7 (i.e. 7x7 tiles)


6. Write to GeoTIFF
Add a GeoTIFF (Geo-referenced Tagged Image File Format) writer to the workspace. Set a destination folder and zip it by clicking the Zip output button; click OK. Connect the StringConcatenator transformer output port to it. Open the writer and in the parameters dialog, set the Raster File Name to the Attribute Value that was created by the StringConcatenator transformer (drop-down). This will fanout the tiles by the attribute value created.

geotiff-writer-parameters.png


The total number of output files will be:

(1x1) + (2x2) + (3x3) + (4x4) + (5x5) + (6x6) + (7x7) = 140

output.png end-raster.png

 

Data Attribution

The data used here originates from data made available by the Government of Austin, Texas. It contains information available to the public domain.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.