Tiling Raster Data with the RasterTiler

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2023.2

Introduction

The RasterTiler transformer is used for taking a raster and breaking it up into either a defined number of tiles or a defined size of tiles. This is not to be confused with the WebMapTiler transformer, which would be used for tilling data for web maps (i.e. Bing or Google Maps). In this example, we will take a digital elevation model of the North Shore Mountains just north of Vancouver, British Columbia, and divide it into 6 GeoTIFF raster tiles.


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

 

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 NorthShoreMountains.dem. This file is a Digital Elevation Model (DEM) of the North Shore Mountains, just north of Vancouver, BC.

cded-reader.png
 

2. Inspect the Data

Run the translation and inspect the data in Visual Preview (if it does not show it automatically, select the View Source Data button on the Reader Feature Type). This DEM has a longer x-axis than its y-axis, so it would be best tiled into more horizontal tiles than vertical tiles. So, we will tile it into three horizontal tiles and two vertical tiles to create six individual tiles.

cded-raster.png


3. Add the RasterTiler Transformer

To create these tiles, we will use the RasterTiler transformer. Add a RasterTiler to the canvas and connect it to the CDED reader feature type. In the parameters, set the Define Tiles By to Number of Tiles. Then, for Columns, set it to 2, and for Rows, set it to 3. We want all of the tiles to be the same size, so change Force Equal Sized Tiles to Yes. You can change the names of the Attributes if you wish, but for this example, we will just use the defaults. Run the workspace.

rastertiler-transformer.png

rastertiler-io.png

 

4. Create a More Descriptive File Name

If we were to write it out to a GeoTIFF now, our naming convention would look like the following image, which isn’t very descriptive.

geotiff-first-output-undesired.png

To make the file name more descriptive, we will use the StringConcatenator transformer to concatenate the column and row names created with the RasterTiler. Add a StringConcatenator to the canvas and connect it to the Tiles Output port on the RasterTiler. In the parameters, change the New Attribute name to RasterTileName. Then, for StringParts, enter the following:

String Type String Value
Constant Row
Attribute Value _tile_row
Constant Column
Attribute Value _tile_column


The Concatenated Results should look like:

Row@Value(_tile_row)Col@Value(_tile_column)

string-concat-transformer.png

 

5. Write to GeoTIFF

Now that the DEM is tiled and we have a descriptive name for it, we can write it out to a GeoTIFF. Add a GeoTIFF (Geo-referenced Tagged Image File Format) Writer to the canvas, set the Attribute Definition to Automatic, and when the Feature Type dialog appears, just click OK; we will modify the parameters in a moment. Connect the new GeoTIFF feature type writer to the Output port on the StringConcatenator. Now that it is connected to our translation, we can modify the Raster File Name. In the parameters, click the drop-down menu next to the Raster File Name and select Open Text Editor. In the Text Editor, set the value to:

@Value(fme_basename)@Value(RasterTileName)

This will fanout the tiles by the name of the DEM, in this case, is NorthShoreMountains, and then append the row and column numbers at the end. If you are having issues viewing the final GeoTIFF files in the Data Inspector, ensure that your background map is turned off.

geotiff-final-output-desired.png

 

cded-raster-tiled.png

 

NB: The differences in the color range in the above images are caused by the Viewer calculating a scale separately for each raster. This only occurs because these numeric rasters need color interpretation to be viewed: the underlying data is perfectly correct! Color rasters would not exhibit the same differences because they would not need special interpretation. If you wanted to visualize this data as a continuous surface, you could add a RasterInterpretationCoercer to the workspace before the RasterTiler to coerce everything into Grey8 (as opposed to Int8) - however, refining the display like this would render the data useless as a DEM.

 

Data Attribution

The data used here originates from open data made available by the Government of British Columbia. It contains information licensed under the Open Government License - British Columbia.

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.