RasterExtentsCoercer Vectorization Example

From fmepedia

By Dmitri Bagh

FME 2010 has got a new very promising transformer called RasterExtentsCoercer. We will see its full power a bit later, probably in 2011, however, it can be useful right now.

RasterExtentsCoercer replaces incoming raster with vector polygon(s). The transformer has three modes:

-- Raster Extents -- Data MBR Extents -- Data Extents

Let's take a simple example to see how these three modes work.

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

Here is the output:

SourceResults
Raster ExtentsData MBR ExtentsData Extents

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

'Data MBR Extents' makes 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:

The transformer carefully separated all data cells from nodata cells, which were produced by 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.

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:

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

Resulting polygons are cleaned - deaggregated, areas with the same elevations are dissolved, holes cut from donuts, colors 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, translation time is over 30 minutes (on Intel Xeon 2.27GHz, 4 Gb of RAM).

We can smooth 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 in setting nodata in order to extract vector polygons.

Workspaces and Data

Attached Files
filesizedate
CDED_DEM.zip1.3 MB09/16/09
DEMVectorization.fmw103.7 kB09/16/09
RasterExtentsCoercer.png20.5 kB09/16/09
Simple.fmw71.0 kB09/16/09
dataMBRextents.png<1kB09/15/09
data_extents.png1.9 kB09/15/09
data_extents_zoomed.png2.2 kB09/15/09
loop.png25.4 kB09/15/09
raster_extents.png1.9 kB09/15/09
simple_workspace.png52.1 kB09/15/09
source.png21.9 kB09/15/09
sourceCDED.png28.7 kB09/15/09
vectorized.png38.5 kB09/15/09
User Comments Add a new comment