FME Version
Files
Introduction
This article demonstrates how to set and work with a point cloud’s classification component. The previous articles in this series demonstrated how to set the colour and intensity components.
To understand the basics of working with point clouds in FME, see Getting Started with Point Clouds and Point Clouds (IFMEPointCloud) documentation. Key transformers for setting component values include the PointCloudOnRasterComponentSetter, which sets them based on an overlaid raster, and the PointCloudExpressionEvaluator, which sets them based on expressions or conditional statements.
The goal of this scenario is to correct a point cloud’s classification values. Sometimes, points can be misclassified since they are based on algorithms. If you have a dataset that contains related information, such as building footprints, you can use it to correct the misclassified points—for example, by setting all points that fall within building footprints to 6 (which means “buildings” according to the ASPRS LAS Specification).
Step-by-Step Instructions
In this scenario, we will correct the misclassification between ground (class 2) and low vegetation (class 3) using pixel values from an orthophoto. Our source data includes a point cloud in LAS format and an orthophoto in MrSID format.
Source data. Left: LAS point cloud. Right: MrSID orthophoto.
We will use raster expressions to determine the color of each pixel in the orthophoto and assign it the correct class. We will use the PointCloudOnRasterComponentSetter to set the class in the output point cloud.
1. Open the starting workspace in FME Workbench
Download the tutorial attachments, and open PointCloudReclassification_Start.fmwt to follow along. The workspace has two readers: a LAS point cloud and a MrSID raster. These are connected to a PointCloudOnRasterComponentSetter transformer to colorize the point cloud using the orthophoto colors, and a PointCloudComponentTypeCoercer to set the point cloud’s RGB color values to UInt8 types.
The point cloud looks like this after passing through these transformers:
With the point cloud colorized, we can now work on re-classifying it.
2. Add a PointCloudSplitter
First, split the point cloud by classification. Add a PointCloudSplitter transformer, and connect it after the PointCloudComponentTypeCoercer.
Open the parameters. Set “Split By” to “classification”, and “Split Type” to “Unique”.
The point cloud will split by the classification and create a new point cloud for each unique classification type. The classification value for each new point cloud will be stored in an attribute called “_classification”. The output from this transformer looks like this in Visual Preview:
Note how we have a point cloud for class 2, another for class 1, and another for class 5.
3. Add a Tester
Next, separate the ground points from the rest of the point cloud. Add a Tester transformer, and connect it to the previous transformer.
Open the parameters. Add one Test Clause to check if the classification is 2:
- Left Value: _classification
- Operator: =
- Right Value: 2
The points with classification 2, i.e. ground points, will go through the “Passed” output port, while the rest of the points, i.e. buildings and vegetation, will go through the “Failed” output port.
Below is the output from the "Passed" port—note how it includes only the points with a classification of 2:
4. Add a RasterBandNodataRemover and a RasterExpressionEvaluator
Next, use a raster expression to check the color of each pixel of the orthophoto, and set the classification based on whether it is green or not.
After the MrSID reader, add two transformers to pre-process the MrSID orthophoto: a RasterBandNodataRemover to make any “Nodata” cells valid, followed by a RasterExpressionEvaluator.
Open the RasterExpressionEvaluator parameters, and add the following Band Expression:
- Interpretation: Preserve
- Expression: if(A[1]-A[0]>=7 && A[1]-A[2]>=7 && A[1]<150,3,2)
This expression checks the color of each pixel. It sets the classification of green pixels to 3 (vegetation), and other colors to 2 (ground).
5. Add a PointCloudOnRasterComponentSetter
Overlay the points identified as ground points (class 2) with the prepared orthophoto. Add another PointCloudOnRasterComponentSetter. Connect the Tester’s “Passed” output to the “PointCloud” input. Connect the RasterExpressionEvaluator “Result” output to the “Raster” input.
Open the parameters, and set “Components to Set” to “Custom”. Add one band as follows:
- Band: 0
- Component: classification
- Default value: 2
Also set “Interpolation Type” to “Nearest Neighbor” so that it doesn’t try to assign calculated average values to the points.
This will refine the point cloud by correcting the points that had the wrong classification.
6. Add a PointCloudCombiner
Add a PointCloudCombiner transformer. Connect both the “Failed” output port from the Tester and the “PointCloud” output from the PointCloudOnRasterComponentSetter to the input port of the PointCloudCombiner.
7. Connect an Inspector
Connect an Inspector so we can view the output in Visual Preview. The final workspace looks like this:
8. Run the workspace
Run the workspace. The output from this transformer will look identical to the original point cloud, but the classification values for ground and low vegetation points will be classified more accurately.
Bonus: Highlighting a specific classification value
Open the workspace PointCloudReclassification_Bonus.fmwt to see an expanded version of this workspace that outputs a point cloud highlighting all points with a specific classification – in this case, 3 (low vegetation).
In the bonus part of the workspace, the PointCloudSplitter splits the point cloud by classification values, and the Tester checks for points where _classification = 3. The RasterRGBCreator creates a 1x1 raster that we’ll use in the PointCloudOnRasterComponentSetter. The PointCloudOnRasterComponentSetter then sets the points with class 3 (low vegetation) as bright green.
The output looks like this:
Left: Original point cloud. Right: With “low vegetation” points (class 3) coloured bright green.
Data Attribution
The data from these exercises originates from data made available by the Ohio Geographically Referenced Information Program. The GIS Support Center maintains enterprise and site licenses for commercial data sets that are supportive of the Ohio Enterprise.
Comments
0 comments
Please sign in to leave a comment.