Overview
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:
Here is the output:
Source
Results:
Raster Extents
Data MBR Extents
Data Extents
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:
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):
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.
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).
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.