Getting Started with FME Form: Working with Spatial Data

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction 

In this article, you'll discover how to create a workspace in FME Workbench, the authoring application accompanying FME Form, specifically emphasizing utilizing spatial (GIS) data. Follow along with the step-by-step instructions to learn how to read data from an OGC GeoPackage that includes points of trash containers and polygons of parks, add a transformer to spatially filter for trash containers within the parks, and then write the filtered data to an Esri Shapefile.

Final-Workspace.png

 

FME Desktop was rebranded to FME Form in 2023. FME 2024.0 features a new interface. This tutorial can be used with any version of FME. The concepts are the same, but the screenshot appearances may differ.

 

Source Data

The source dataset is an OGC GeoPackage containing trash container points and park polygons. 
InputData.png
 

Step-by-step Instructions

1. Start a Blank Workspace
Start FME Workbench, then click the Blank Workspace button.
BlankWorkspace.png

The FME Workbench canvas is where the workspace will be built using readers, writers, and transformers. 
CanvasOverview.png

2. Add an OGC GeoPackage Reader
On the top menu bar, click Readers, then select Add Reader. A reader is an object in a workspace that reads a source dataset. 
AddReader.png

In the popup Add Reader dialog, type in OGC GeoPackage as the Format. Then click the ellipsis [...] button next to Dataset and browse to the City.gpkg sample dataset. Other parameters are available, but you can leave them as default for this example. Click OK to add the reader to the workspace. 
Reader.png

Since this dataset has multiple tables, you will be prompted to Select Feature Types (Table). We need both tables, click OK; both tables should be selected by default. 
ReaderFT.png

Readers create a feature type for each table or layer in the source dataset you wish to read. In this case, two reader feature type objects have been added to the canvas and represent each table in the GeoPackage. 
ReaderFTCanvas.png

The Navigator is where readers can be found. The A) reader represents the dataset as a whole, such as the entire City.gpkg dataset. The B) reader feature types represent each part of the dataset, in this case, the parks and trash_container layers. 
Navigator.png


3. Add a Transformer
Transformers are the building blocks within a workspace to manipulate data, and each has a specific function. We will use a SpatialFilter transformer to filter the trash_containers to only the containers that intersect a park.  

Click on a blank space on the canvas, and start typing SpatialFilter to bring up the Quick Add dialog. The Quick Add dialog is where readers, writers, and transformers can be added. Double-click on the SpatialFilter under FME Transformers to add it to the canvas.
QuickAdd.png

To access the data from within the transformer, it needs to be connected to the workflow. Click and drag from the arrow on the parks reader feature type to the red arrow of the Filter input port on the SpatialFilter transformer. This connection line sends data from the feature type into the transformer for processing.
Connection.png


Next, connect the trash_container reader feature type to the Candidate input port on the SpatialFilter. 
BothConnected.png

4. Review Transformer Parameters
The SpatialFilter uses spatial predicates as filters. The test we will need to perform is Filter OGC (trash_containers) - Intersects Candidate (parks). Double-click anywhere on the SpatialFilter to open the parameters. By default, the SpatialFilter is already set to Filter OGC - Intersects Candidate. Since we do not need to change the Spatial Predicate to Test parameter, we can click OK or Cancel to accept the default parameters. 
SpatialFilter.png

5. Add a Writer
So far, we have only created instructions for what  FME Workbench should do. To store the resulting data to use later or for use within a different application, we need to write it out.  This is accomplished with a writer. 

On the top menu bar, click on Writers to open the drop-down menu, then select Add Writer.
AddWriter.png

In the Add Writer popup dialog, select Esri Shapefile as the Format. Then for Dataset, click on the ellipsis and browse to a folder to store the shapefile. FME can read and write the same file and create new files in any supported format. Ensure that Shapefile Definition is set to Copy from Reader. Click OK to finish adding the writer to the canvas. 
Writer.png

We used the Copy from Reader Shapefile Definition; this parameter will copy the schema from one of the reader feature types. Since our output will be the filtered trash_containers, select trash_containers as the reader feature type to copy. Click OK. 
SelectFT.png

Since we copied the schema from the trash_container reader feature type, the writer feature type has the same attributes and point geometry that the input had. 
WriterFT.png

The writer feature type needs to be connected to the workflow. Click and drag from the SpatialFilter Passed output port arrow to the red arrow on the trash_container writer feature type. 
Workspace.png

6. Run the Workspace
The workspace will read the data and filter for the trash_containers intersecting parks and then write the filtered trash_containers to an Esri Shapefile, but we still need to run the workspace. Running the workspace with a writer connected will write the data out to disk. On the top toolbar (ribbon), click the green Run button. Clicking Run will trigger the workspace to read the data, process it through any transformers, and then write it out. 
RunWorkspace.png

After clicking Run, a Translation Parameter Value dialog will pop up; this is where any user-defined parameters can be modified. We do not need to make any changes at this time; click Run to continue.  
Prompt.png

After initiating the workspace to run, data will flow through the workspace. The numbers on the connection lines represent the number of features it is transporting, and the number on each output port is the number of features that is output. A feature in FME is a single row in a table or a single piece of geometry with associated attributes.  


7. View Output
After running the workspace, green eye icons appear on any of the output ports that have features. These icons represent cached data and can be used to view data at any part of the workspace. 

Note: In FME 2023.2 or prior, the inspect/cached data icon is a magnifying glass. 

Since our data was written to disk, we need to view the final output. Single-click on the trash_container writer feature type to open the popup menu. Then click on the View Written Data button to open the data in Visual Preview. 
ViewWritten.png

Visual Preview is the data viewer within FME Workbench. There is also an external application to view data called FME Data Inspector. In the Visual Preview window, you will see only the trash_containers that intersect parks. 
Inspect.png


OutputData.png
Note that the above screenshot contains a background map and the park polygons. For more information on viewing data and background maps, see the documentation

 

Continue Your FME Journey  

 

Want to learn about a specific format?


Want to continue learning FME Form basics?

  • The FME Academy is a guided, on-demand way to learn the entire FME Platform, and it's FREE! 

 

Interested in self-serve and automation?

 

Have a specific question?

 

Data Attribution 

The data used here originates from data made available by the City of Surrey, British Columbia. It contains information licensed under the Open Government License - Surrey.  

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.