Files
-
- 80 KB
- Download
Introduction
In FME, a buffer can be created around a geometry using a width extracted from an attribute. Using an attribute value as the buffer size can be useful in scenarios where the geometry's size needs to be variable or dynamic, such as pipe diameter, road width, catchment areas, zoning, and more.
The key transformer for creating buffers is the Bufferer, which works with point, line, and polygon features. The Bufferer can take a constant value or an attribute as the buffer size. To create an expression based on an attribute value, use the ExpressionEvaluator transformer.
Step-by-Step Instructions
We will use GPS points and vehicle speed data to create a geometry that demonstrates traffic flow and congestion points. We will create buffer polygons using vehicle speed as the dynamic attribute value.
1. Open FME Workbench
Open FME Workbench and create a new workspace.
2. Add a CSV Reader
First, we will read the GPS points from a CSV file.
Click Add Reader and set the following parameters:
- Format: CSV (Comma Separated Value)
- Dataset: <Path to tutorial download>/journey.csv
Click Parameters to preview the data. Note how in the “Attributes” section at the bottom, the CSV reader automatically labels the lat/long fields as x and y coordinates—in other words, it automatically generates points from the data. For more information, see Converting from CSV to spatial features.
Click OK to add the reader to the workspace.
When viewed in Visual Preview, the source GPS points look like this:
3. Add a Reprojector Transformer
Next, we will reproject the coordinate system from its current LL84 to the British National Grid (EPSG:27700).
Add a Reprojector transformer and connect it after the reader feature type.
Open the parameters and set the following:
- Source Coordinate System: LL84
- Destination Coordinate System: EPSG:27700
Click OK.
4. Add an ExpressionEvaluator Transformer
Now we will create an attribute named “_buffer” to store the buffer size.
Add an ExpressionEvaluator after the Reprojector.
Open the parameters and set the following:
- Result: _buffer
-
Arithmetic Expression:
@Value(Speed)*4
Click OK.
5. Add a Bufferer Transformer
Add a Bufferer transformer after the ExpressionEvaluator.
Open the parameters. Use the down arrow to set “Buffer Distance” to the new attribute, _buffer.
Leave the other parameters as their defaults. Click OK.
If you run the workspace up to this point and inspect the results of the Bufferer in Visual Preview, you’ll see that each GPS point has been given a buffer, creating a sequence of individual polygons. When we zoom in, it looks like this:
Next, we want to convert this sequence of polygons into a single polygon.
6. Add a Dissolver Transformer
Add a Dissolver transformer after the Bufferer to dissolve the polygons into a single polygon. Leave the parameters as their defaults.
The Bufferer transformer includes a Group By option that can be used to combine buffers. This option is helpful when the buffer size is constant. However, in this scenario, since the size of the buffer is not equal (variable size), this option will not work.
7. Add an Inspector
Connect an Inspector after the Dissolver’s Area output port. This will send the output to Visual Preview instead of writing it to an output format.
The final workspace looks like this:
8. Run Workspace and Visualize Output
Click Run Workspace. Inspect the output in Visual Preview. Note how the size of the polygon changes depending on the speed values at each point along the line. The narrow areas indicate slower speeds, i.e., congested areas or bottlenecks.
The image below shows the buffered polygon overlaid on the source dataset. Bottlenecks with lower speed values are outlined in red:
You have successfully created a workspace that uses the source data’s speed attribute to buffer the geometry.
Additional Resources
Other useful transformers for creating variable-width buffers include:
- Chopper – for chopping lines into individual points
- Generalizer – can be used before buffering complex objects to reduce the number of points or smooth the geometry
- LineCombiner and Snapper – can be a helpful sequence of transformers when buffering line features
Data Attribution
The data used in this example originates from Open Street Map and is available under the Open Database License. © OpenStreetMap contributors
Map tiles by Stamen Design, under CC-BY-3.0. Data by OpenStreetMap, under CC-BY-SA.