Raster to Vector - Centerline Extraction (2010 Edition)
Back in 2008, I made a centerline extraction demo
. I mentioned in that article that the only way FME could convert raster to vector is through the
RasterToPointCoercer, which was later renamed to
RasterCellCoercer due to updated functionality (now, it can change cells not only to points but also to polygons).
In 2010, we got a better tool that allows accomplishing the same task much more effective - I already published an
article showing how the
RasterExtentsCoercer can be used for vectorization.
Now we don't have to deal with making points, transferring raster cell values, replacing points with polygons, and dissolving them.
With the first step, we prepare our raster to vectorization using the RasterExpressionEvaluator:
if((abs(A[0]-A[1]) <= 3 && abs(A[0]-A[2]) <= 3) || (abs(A[0]-A[1]) <= 4 &&(A[0]-A[2]) > 20), 0,255)
The expression above makes all roads black, and sets the rest to white, which becomes NODATA in the next transformer (
RasterBandNodataSetter). After that, we are ready to make vector from all the roads - this is the place where we need the
RasterExtentsCoercer.
As result, a big portion of the workspace made in FME 2008 becomes unnecessary (including four custom transformers) - in the picture below, it is shown as hatched red area:
We replaced all that with just three transformers:
But what is even more important, by doing this, we significantly improved performance:
FME 2008 FME 2010
RasterToPointCoercer RasterExtentsCoercer
5 minutes 18.0 seconds 7.9 seconds
On a bigger raster, this difference will be even more noticeable.
Downloads
The updated workspace (See Attachment: centerlineextractor2010.fmw)
The source raster (See Attachment: raster2.png)