Creating KML Folders By Feature Type Fanout

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

KML Folders define the nested tree structure in the Google Earth Places pane (as shown below). This tree control helps organize data presentation for the user, allowing them to turn on and off layers of interest. It also helps group features together so the user isn’t presented with a list of thousands of features. For example, instead of a hundred different zoning types, you might want to organize your zone features into zone categories such as commercial, residential, industrial, transportation, and open space.

kml-folders-example1.png

KML Folders: Approaches in FME

FME allows you to create KML folder structures in two ways:

  1. The feature type fanout approach (this tutorial)
  2. Through the use of KML_IDs (the next tutorial)

These two approaches are intended for use with KML, not KMZ (which is a zipped KML file). In this example, we will focus on the fanout approach, a feature type. Using Vancouver’s SkyTrain stations from a CSV file and Vancouver zones from a MapInfo file, we will create a KML that groups stations together by zone. This is a great way to organize features in the Google Earth legend, especially if you have numerous features that can be logically aggregated.

Step-by-step Instructions

1. Read Source Datasets

In a blank FME workspace, add a Comma Separated Value (CSV) reader to the canvas and browse to the rapid_transit_stations.csv dataset. Set the Coordinate System to UTM83-10, then open the Parameters.

As of FME 2025.2, the Coordinate System parameter is now configured within the Parameters dialog of each reader/writer format. For more information, including details about the change and affected transformers, please see Coordinate System Parameter Location Change.

CSVReader.png

In the parameters, change the Feature Type Name(s) to From File Name(s), then change the Attribute Definition to Manual. Now we need to set the attribute types so that FME will create points from our data. Set x to x_coordinate, and y to y_coordinate, then click OK twice to add the reader.

CSVParams.png

For FME 2025.2 and newer, enable Create Point Geometry From Attributes in the Parameters dialog, then set the Coordinate System.

Next, add a MapInfo Tab (MITAB) reader to the canvas and browse to the Zones.tab dataset that is available for download from the Files section on this article. We can accept the default parameters. 
MitabReader.png

2. Overlay Train Stations on Zones

Next, we will use the PointOnAreaOverlayer to merge the ZoneCategory attributes from the Zones dataset, onto the station points. Add a PointOnAreaOverlayer transformer to the canvas. Connect the rapid_train_stations reader feature type to the Point input port, then connect the Zones reader feature type to the Area input port. 
POAOConnections.png

In the PointOnAreaOverlayer parameters, expand the Attribute Accumulation section, then enable Merge Attributes. 
POAOParams.png

3. Clip Stations to Zones

If you inspected the data at any point, you may have noticed that the zones don’t cover all of the train stations. Now, we will clip our stations to the zone areas. Add a Clipper to the canvas, then connect the Zones reader feature type to the Clipper input port. Next, connect the Point output port on the PointOnAreaOverlayer to the Clippee input port on the Clipper. 
ClipperConnection.png
If you don’t like that your connection lines are crossed, you can change the order of the ports on the Clipper. Right-click on the Clipper port and select Move Down. 
Reorder.png

Note that if you are looking for a quick way to make folders, you can skip to step 7 where we add the writer and connect it directly to the Inside output port on the Clipper. 

4. Clean Up Attributes

Both the PointOnAreaOverlayer and the Clipper create attributes we don’t need. Add an AttributeManager to the Inside output port on the Clipper. In the parameters, rename 'STATION' to 'Station', then remove '_overlaps' and '_clipped'. 
AttributeManager.png

5. Filter Zones For Styling

Taking a quick glance at our station and zone data in the visual preview, we can see that our train stations only fall into three of the 7 possible zones: Commercial, Development, and Light Industrial. 
VP.png

We will filter these out so that we can apply different styles to the output later. Add a TestFilter to the canvas and connect it to the AttributeManager. In the parameters, create the following tests: 

  Test Condition Output Port
If ZoneCategory = Commercial Commercial
Else If ZoneCategory = Comprehensive Development Development
Else <All Other Conditions Light Industrial

TestFilter.png

If you ran the workspace with Feature Caching Enabled before this step, you can take advanced of the TestFilter being data-aware. This means that when you go to type in the attribute value for the test condition, the attribute value will appear without needing to be typed out in full, or you can select it from the drop-down menu. 
DataAware.png

6. Style KML

We will have three KML folders: Commercial, Comprehensive Development, and Light Industrial, when we set our fanout to ZoneCategory. This step is simply for visualization so we can tell the points apart quickly. Add a KMLStyler to each of the output ports on the TestFilter, there should be three in total. 
ConnectKMLStylers.png
In the first KMLStyler, expand the Icon section, then set the Icon Name to gme/gx_rail, then set the Color to purple. Repeat this step for the other two KMLStylers, selecting blue and yellow as the colors. 
KMLStyler.png

7. Write out to OGC/Google KML Using Feature Type Fanout

Our data is ready to be written out. Add an OGC/Google KML writer to the canvas and browse to a location to save the dataset. Name the file KMLFolders_Fanout.kml and set the Feature Type Definition to Automatic. 
KMLWriter.png

In the Feature Type dialog, click OK to accept the default. Then connect the writer feature type to all three KMLStylers. Once it is connected, reopen the parameters. 
WriterConnection.png

In the writer feature type parameters, click on the drop-down next to Feature Type Name and select the ZoneCategory attribute. 
WriterParams.png

8. Run the Workspace and View the Output in Google Earth

Run the workspace, then open the containing folder and view the output in Google Earth
GoogleEarth.png

In the Navigation Tree you will see the individual folders that we created with the feature type fanout. 
FolderStructure.png
 

Data Attribution

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

Was this article helpful?

We're sorry to hear that.

Please tell us why.

As of January 14th, 2026, comments on knowledge base articles have been closed. To make sure questions don’t get missed and to enable more community support, we’ve moved discussions to the FME Community. If you have a question or a comment about this article, please create a new post or create a support ticket.