Sample and Demos

DEM Raster to Vector with RasterExtentsCoercer

Article Number: 000001651 - Last Modified: Nov 1, 2011

Replaces the geometry of input raster features with a polygon covering the extents of the raster. In this example, it is used to support vectorization of an input DEM into classified elevation vector polygons.


The RasterExtentsCoercer replaces incoming raster with vector polygon(s) that encompass the raster extents. With the 'Data extents' setting, it can be used to generate polygons for areas that exclude no data values.

The transformer has three modes:
  • Raster Extents
  • Data MBR Extents
  • Data Extents
Let's take a look at a simple example (attached: simple.fmw) to see how these three modes work.

RasterExtentsCoercer Modes

RasterRGBCreator will generate a source raster, which we pass to three RasterExtentsCoercers set to three different modes:

User-added image

Here is the output:

User-added image


Raster Extents    

User-added image

Data MBR Extents  

User-added image

Data Extents

User-added image            

In the simplest case of 'Raster Extents', we get the same result as if we were using a BoundingBoxReplacer. In our example, the RasterRGBCreator applies a 25-degree rotation to the raster, so the rotated corners of the raster are used.

'Data MBR Extents' creates a Minimal Bounding Rectangle around all data cells within the raster. In our case, we have data cells touching all four sides of the raster, this is why the resulting polygon is equal to the raster extents.

Now, let's have a closer look at the last mode - 'Data Extents'. If we zoom closer, we can see a zig-zagy edge of the vector polygon:
User-added image

The transformer carefully separated all data cells from nodata cells, which were produced by the raster rotation. This last mode is quite interesting, although still limited. If we can separate data from nodata, then we can dynamically change nodata value, and hence - consecutively vectorize different values (and areas) of the image.

DEM Raster to Vector Example

The best candidate for such a test is a DEM raster. I took a couple of CDED DEMs, and used them as a source for a bigger experiment (see DEMVectorization.fmwt):
User-added image

With the RasterExpressionEvaluator, I transformed all the elevations to multiples of 20. In the custom transformer, I made a loop that changes the nodata value from 0 to the maximum available on rasters with 20 meters interval.

User-added image

Resulting polygons are cleaned, deaggregated areas with the same elevations are dissolved, holes are cut from donuts, and colors are set according to elevation:

We have got a vector dataset. The whole translation time is about 10-12 seconds. If we do it the old way with RasterCellCoercer, PontOnRasterValueExtractor, and 2DBoxReplacer, the translation time is over 30 minutes (on Intel Xeon 2.27GHz, 4 Gb of RAM).

User-added image
We can smooth the resulting polygons with our Generalizer transformer, however, this task is outside of the scope of this article.

Future versions of this transformer will be able to deal with data values and ranges - there will be no need for setting nodata in order to extract vector polygons.

Suggested Similar Articles

Introduction into Minecraft world making with FME 2015

Overview of raster processing in FME.

Several examples of how the RasterInterpretationCoercer can help you optimize your raster data for display or further processing.

The RasterCellCoercer vectorizes raster data by converting each cell into either a point feature or polygon feature.

PDF format is a destination format designed for displaying 3D data in Adobe PDF files.