Using the PointCloudFilter

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

Point cloud datasets can contain a lot of information that isn’t required for what you are trying to achieve. To help filter out points of interest, we can use the PointCloudFilter transformer. The PointCloudFilter uses an expression to filter the points of interest, which will then reduce the output size when writing the data back out.

 

Step-by-step Instructions

Filtering point clouds on the Z-axis is the most common application of filtering. Removing roofs off buildings, selecting only the ground, and setting elevation bands are all done with Z filtering. Depending on the complexity of the filter, you can use a single filter or multiple filters within a single PointCloudFilter transformer to achieve your results.

 

Single Filter

To remove a roof of a building, we need to know the range of vertical extents of the ground and where the roof begins. This can be determined by opening up the dataset in the FME Data Inspector, or Visual Preview.

 

1. Open FME Data Inspector

In the FME Data Inspector, click on the Open button and select ASPRS Lidar Data Exchange Format (LAS) as the Format. Browse to the house.las file included in Z Filtering\Data folder.

house-datasettoview.png

 

2. Select Min and Max extents

Now, ensure that the Feature Information window is open and click on the lowest point you are interested in. Then viewing the value in the Feature Information Window, record the value for the Z component. In this case, we will use -1.97.

house-lowerextent.png

 

Repeat with the upper extent. Click on the highest point you are interested in. You might need to zoom in a bit to accurately click on the points. Then record the value for the Z component. In this case, it is 2.44.

house-upperextent.png

 

This range represents the vertical extent we wish to filter.

 

3. Open FME Workbench

Open a blank workspace in FME Workbench. Add an ASPRS Lidar Data Exchange Format (LAS) reader and browse to the house.las dataset.

house-reader.png

4. Add a PointCloudFilter Transformer

Next, add a PointCloudFilter transformer and connect it to the reader. In the parameters, click on the ellipsis under Expression to open up the Arithmetic Editor - ‘Point Cloud Filters’ dialog.

pointcloudfilter.png

 

In the editor, expand the Point Cloud Component section and double click on z.

zcomponent.png

 

Now set up the rest of the expression using the values we recorded from the FME Data Inspector. When creating a range with the expression, use && instead of AND.

@Component(z) > -1.97 && @Component(z) < 2.44

 

house-expression.png

Click ok, and set the value of the Output port to House. Click ok again to save the parameters.

 

5. Run the translation

Now either add an Inspector transformer to the House output port or run the workspace with Feature Caching enabled.

 

Run the workspace and then view the output for the House port in either FME Data Inspector or Visual Preview.

house-output.png

 

As you can see, the roof is now filtered, and you can see inside the building.

 

Multiple Filters

Using the PointCloudFilter with multiple filters and the FeatureColorSetter transformers, we can also divide the point cloud into sections and add coloring. For this example, we will divide a point cloud depicting an elevation model and divide it into five sections, then add color. Another method of doing this would be to use the PointCloudSplitter. For more information see the article PointCloudSplitter: Splitting Point Clouds By Components.

 

1. Open FME Data Inspector

In the FME Data Inspector, click on the Open button and select ASPRS Lidar Data Exchange Format (LAS) as the Format. Browse to the mountain.las file included in Z Filtering\Data folder.

 

Then once the data is loaded, find the min and max extents for the area you want to color. To do this, use the Select tool and drag a box over the entire point cloud. Then in the Feature Information window, you should see Min Extents and Max Extents. We are interested in the Z extent, which will be the last value in each row.

mountain-extents.png

 

So our min Z extent is 242.2, and our max Z extent is 412.35

 

2. Open FME Workbench

Open a blank workspace in FME Workbench. Add an ASPRS Lidar Data Exchange Format (LAS) reader and browse to the mountain.las dataset.

 

Next, add an ExpressionEvaluator to the canvas. We will be using the ExpressionEvaluator to divide the difference between the max and min values by 6; this will be the value we use to break the elevation into equal parts.

 

In the ExpressionEvaluator, set the following equation:

(412.35 - 242.2)/5

 

3. Add a PointCloudFilter

Now we have an attribute called _result that has the value of 34.03000000000001, which we will use in the PointCloudFilter expressions to build a range of equal interval filters. Add a PointCloudFilter to the canvas and connect it to the ExpressionEvaluator.

 

In the PointCloudFilter parameters, set the following expressions:

Expression

Output Port

@Component(z) > 242.4 && @Component(z) < (242.2+@Value(_result))

1

@Component(z) > (242.4+@Value(_result)) && @Component(z) < (242.2+(@Value(_result)*2))

2

@Component(z) > (242.4+(@Value(_result)*2)) && @Component(z) < (242.2+(@Value(_result)*3))

3

@Component(z) > (242.4+(@Value(_result)*3)) && @Component(z) < (242.2+(@Value(_result)*4))

4

@Component(z) > (242.4+(@Value(_result)*4)) && @Component(z) < 412.35

5

 

These expressions define a range between the lowest value of Z and the highest value of Z in that range. Using the _result attribute, we can multiply it by however many times it would occur in that range.

Note that the PointCloudFilter transformer doesn’t have a copy and paste button for the lines (like in the Tester). To copy and paste, open up the equation, and then copy it.

mountain-pcfexpression.png

 

By default the PointCloudFilter will output unfiltered points. If you leave this set to Yes, there will be some unfiltered points that results from using whole numbers in the equation. Let’s set Output Unfiltered Points to No to prevent any confusion in the next steps.

mountain-pointcloudfilter.png

 

4. Add FeatureColorSetters

The final step is to color each of the ranges with a specific color. Connect a FeatureColorSetter transformer to each of the five output ports. Then in each of the FeatureColorSetters, set the Color Scheme to Fixed and then set the Pen Color according to the following table:

 

PointCloudFilter Output Port #

FeatureColorSetter Pen Color

1

Light Blue (0.333333,0.666667,1)

2

Green (0.333333,0.666667,0)

3

Peach (1,0.666667,0.498039)

4

Yellow (1,1,0)

5

Red (1,0,0)

 

 

Once all the FeatureColorSetters are set up, add an Inspector transformer and connect it to all five FeatureColorSetters.

mountain-featurecolorsetter.png

 

5. Run the Workspace

Run the workspace and view the result in FME Data Inspector or Visual Preview. There should be a point cloud with five different colors. Feel free to change the colors as desired.

mountain-output.png

 

Data Attribution

The data for the Single Filter exercise originated from Sketchup 3D-Warehouse and was transformed into a point cloud using FME.

The data for the Multiple Filter exercise originates from West Virginia View. They are sponsored by AmericaView and the USGS.

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.