> For the complete documentation index, see [llms.txt](https://1spatial.gitbook.io/fme-form-beginner/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://1spatial.gitbook.io/fme-form-beginner/transformer-usage/conditional-filtering/transformer-usage-exercise-2.md).

# Transformer Usage - Exercise 2

<table><thead><tr><th width="176">Exercise Details</th><th>Noise Control Laws Project (Conditional Filtering)</th></tr></thead><tbody><tr><td><strong>Locality</strong></td><td>Vancouver, Canada</td></tr><tr><td><strong>Data</strong></td><td>Addresses (File Geodatabase)<br>Zoning (MapInfo TAB)<br>Roads (AutoCAD DWG)</td></tr><tr><td><strong>Overall Goal</strong></td><td>To find all residential addresses within 50 meters of an arterial highway</td></tr><tr><td><strong>Demonstrates</strong></td><td>Methods of conditional filtering</td></tr><tr><td><strong>Start Workspace</strong></td><td>C:\FMETraining\Workspaces\Transformers-Ex2-Begin.fmw</td></tr><tr><td><strong>End Workspace</strong></td><td>C:\FMETraining\Workspaces\Transformers-Ex2-Complete.fmw</td></tr></tbody></table>

As you know, city councillors have voted to amend noise control laws and residents living in affected areas must be informed of these changes. You have been recommended by your manager to take on the task, and there's a tight deadline.

In the first part of the project, you created a workspace to convert addresses from Geodatabase to CSV, mapping the schema at the same time.

This exercise is the second part of the project: locating all affected residents. You must locate all single-family residences within 50 meters of a major highway and filter out all others from the stream of address data.

***

{% stepper %}
{% step %}

## Start FME Workbench

Start FME Workbench (if necessary) and open the workspace from Exercise 1. Alternatively, you can open C:\FMETraining\Workspaces\Transformers-Ex2-Begin.fmw

<figure><img src="/files/L1f03iL2deD3ixQtt1VH" alt=""><figcaption></figcaption></figure>

The workspace already has a FeatureReader to read addresses, transformers to edit the address schema, and a writer to write data to an CSV spreadsheet.
{% endstep %}

{% step %}

## Add Roads Data Reader

Use Readers > Add Reader to add a reader for the roads data. The roads data will be used to the determine distance from an arterial route.

<table><thead><tr><th width="176">Parameter</th><th>Value</th></tr></thead><tbody><tr><td><strong>Reader Format</strong></td><td>Autodesk AutoCAD DWG/DXF</td></tr><tr><td><strong>Reader Dataset</strong></td><td>C:\FMETraining\Data\Canada\Transportation\CompleteRoads\CompleteRoads.dwg</td></tr></tbody></table>

When prompted, select only the feature type called **Arterial**.
{% endstep %}

{% step %}

## Add Zoning Data Reader

Use Readers > Add Reader to add a reader for zoning data. The zoning data will be used to determine whether an address is single-family residential or not.

<table><thead><tr><th width="176">Parameter</th><th>Value</th></tr></thead><tbody><tr><td><strong>Reader Format</strong></td><td>MapInfo TAB (MAPINFO)</td></tr><tr><td><strong>Reader Dataset</strong></td><td>C:\FMETraining\Data\Canada\Zoning\Zones.tab</td></tr></tbody></table>

With attribute lists collapsed, the workspace will now look like this:

<figure><img src="/files/bH1673FZq7E5E8yvl25B" alt=""><figcaption></figcaption></figure>

Feel free to inspect all of the source data to familiarize familiarise yourself with the contents. You can even run the workspace to make sure all caches are up to date.
{% endstep %}

{% step %}

## Add a Tester Transformer

Add a Tester transformer to the Zoning feature type.

This Tester will be used to filter residential zones from the other zoning areas. All single-family residential zones will start with RS, so the Tester should be set up like this:

<figure><img src="/files/GfG8gFR69muWGHQAKA9m" alt=""><figcaption></figcaption></figure>

The important thing is to set up the test with the “Begins With” operator.
{% endstep %}

{% step %}

## Connect Tester to the Feature Reader

One way to filter data is to use a SpatialFilter transformer, and we will do this with the road features. But another method is to use filtering inside the FeatureReader transformer.

So, connect the Tester:Passed port to the FeatureReader:Initiator port:

<figure><img src="/files/kAWdTCMnC4rnGWNfB60S" alt=""><figcaption></figcaption></figure>
{% endstep %}

{% step %}

## Set up the FeatureReader

Now inspect the FeatureReader's parameters. Set the Spatial Filter parameter to *Initiator OGC- Contains Result*:

<figure><img src="/files/8lQfbNq7kAIzmBOlRbPn" alt=""><figcaption></figcaption></figure>

This ensures that only addresses that fall inside a Single Family Residence zone will be read from the database. Make sure feature caching is turned on and run the workspace to the FeatureReader. Inspect the Tester:Passed and FeatureReader:PostalAddress caches to confirm that the results are correct.

For the Tester, there should be 19 features coming from the Tester:Passed output port. The FeatureReader:PostalAddress output port will now only have 1853 features, compared to the 13597 features before we filtered by zone.
{% endstep %}

{% step %}

## Add Bufferer Transformer

Now we can determine which of the filtered addresses fall within 50 meters of an arterial route. First, we will need to add a Bufferer transformer to set the 50-meter distance around the roads.

Add a Bufferer transformer to the workspace. Connect it to the Arterial roads data:

<figure><img src="/files/bzVG0TXt1FLADGguNxrA" alt=""><figcaption></figcaption></figure>

Set the Bufferer Buffer Distance parameter to be 50 and Distance Units to be Meters..

{% hint style="info" %}
**TIP**

*Optionally you can set the Dissolve on Attributes parameter, to merge all the buffered features together based on an attribute like the fme\_feature\_type.*

*The results of the translation will be the same (in terms of addresses selected) but the data will look better in Visual Preview.*
{% endhint %}
{% endstep %}

{% step %}

## Add a SpatialFilter Transformer

Add a SpatialFilter transformer. The buffered arterial routes are the Filter. The Candidate port can be connected between the FeatureReader and the AttributeSplitter:

<figure><img src="/files/qeVt0mUfKf3ASV8CLCpH" alt=""><figcaption></figcaption></figure>

This way the AttributeSplitter and AttributeManager are operating only on filtered features. If the SpatialFilter was connected after the AttributeManager, then data would be getting processed and then discarded.
{% endstep %}

{% step %}

## Set SpatialFilter Parameters

Set up the SpatialFilter parameters as follows:

<table><thead><tr><th width="185"></th><th width="221">Value</th><th>Reason</th></tr></thead><tbody><tr><td><strong>Filter Type</strong></td><td>Multiple Filters</td><td>There are multiple buffer polygons</td></tr><tr><td><strong>Pass Criteria</strong></td><td>Pass Against One Filter</td><td>A single address cannot be in all buffers</td></tr><tr><td><strong>Spatial Predicates to Test</strong></td><td>Filter Contains Candidate</td><td>Find addresses contained in the arterial buffers</td></tr></tbody></table>

<figure><img src="/files/yQwkNRzbM0fezRcl3c9Z" alt=""><figcaption></figcaption></figure>

That is, there are multiple road buffers, but an address only has to be inside one buffer to pass, not all of them.
{% endstep %}

{% step %}

## Run the Workspace

Run the workspace by pressing F5 and check the output to confirm the dataset has been written correctly. There should be 148 records in the spreadsheet, ready to send to the administration department for a bulk mailing.
{% endstep %}
{% endstepper %}

***

{% hint style="success" %}
**CONGRATULATIONS**

By completing this exercise, you have learned how to:

* Use the Tester transformer to filter by an attribute value
* Use the Spatial Filter option in the FeatureReader transformer
* Use the Bufferer transformer to set up a "within x distance of" test
* Use the SpatialFilter transformer to filter by geometry
  {% endhint %}


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## Querying This Documentation
If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://1spatial.gitbook.io/fme-form-beginner/transformer-usage/conditional-filtering/transformer-usage-exercise-2.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
