Modify Raster Cell Size by Resampling

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2022.0

Introduction

In this tutorial, you will learn how to modify raster cell sizes using the FME RasterResampler transformer. The RasterResampler resamples an input raster based on user-specified parameters (raster dimension, cell size, or percentage of size) and an interpolation method (Nearest Neighbor, Bilinear, Bicubic, Average 4, or Average 16) to merge cells.

resampling-demo.png

 

Step-by-step Instructions

In this scenario, you want to change the spatial resolution of your raster dataset and set rules for aggregating or interpolating values across the new pixel sizes. This will allow you to change the cell size without changing the extent of the raster dataset. The objective of this exercise is to downsample the raster in order to reduce the file size and improve performance when displaying the raster.

Source
The source dataset is a digital elevation model of mountains in British Columbia with a 1201 x 1201 px resolution. 
Input.png

1. Create a New Workspace
Open FME Workbench and create a blank workspace. 
NewWorkspace.png
 
2. Add a Canadian Digital Elevation Data (CDED) Reader
Add a Canadian Digital Elevation Data (CDED) reader to the canvas by clicking on the Reader button on the top menu bar or by going to Readers > Add Reader. In the Add Reader dialog, select Canadian Digital Elevation Data (CDED) as the Format, then for Dataset, browse to the DEM-Full.dem dataset, which is available for download from the Files section on this article. Then click OK to finish adding the reader.
Reader.png
 
3. Resample Raster
Click on the CDED reader feature type to select it.  Then add a RasterResampler transformer to the canvas by typing “RasterResampler” to bring up the list of FME Transformers in the Quick Add Search. Select the RasterResampler from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. 
quickAdd.png
Connection.png

 
Double-click on the RasterResampler to open the parameters. In the parameters, change the Resolution Specification to Percentage, then enter 50 into the Percentage parameter. Next, set the Interpolation Type to Average 4, then click OK. 
 RasterResample.png
 
Average 4 and Average 16 are useful interpolation types for numeric rasters like DEMs and produce higher quality images than Bilinear and Nearest Neighbor. For more information, see the RasterResampler documentation.
Note: Another common practice is to create raster pyramids to improve performance. To find out more about using the RasterPyramider in FME, see the Raster Pyramiding Example article.
 
4. Add an Esri ASCII Grid Writer
Add an Esri ASCII Grid writer to the canvas, the same way a reader is added. Browse to the Output folder and then change the DEM File Definition to Automatic. Click OK to finish adding the writer. 
Writer.png
 
In the Feature Type dialog, set the DEM File Name to ResampledRaster. Next, change TAB File Generation to Yes, then click OK. TAB files are used to store control points, a coordinate system, and user attributes. To learn more about TAB files, see the Raster documentation.
WriterParams.png
 
5. Run the Workspace
Connect the ResampledRaster writer feature type to the Resampled output port on the RasterResampler.  
Workspace.png 

Run the workspace by clicking on the Run button on the top toolbar, or by using Run > Run Workspace on the top menu bar. 

 
After running the workspace, click on the ResampledRaster writer feature type to open the popup menu, then click on View Written Data to view the data in Visual Preview. 
 
In Visual Preview, click on data to select it, then open the Feature Information Window. In the Feature Information Window, notice that the Resolution has been decreased by 50% from 1201x1201 to 601x601.
Output.png

 

Data Attribution

Data used in this tutorial originates from open data made available by the Government of Canada. It contains information licensed under the Open Government Licence - Canada.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.