Setting KML Regions and Display Criteria

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2020.0

Introduction

Writing a basic KML dataset, without complex node types or feature styling, is easy with FME. FME will attempt to preserve any source styling when writing KML output.

 

Video

See how to create KML data and style it. We'll look at attributes, regionation (display scales), coordinate systems, balloons, and other styling, This demo converts MapInfo .TAB to KML. This video was recorded in an older version of FME. The interface will be different but the concepts are the same.

 

Step-by-step Instructions

1. Open FME Workbench

In a blank workspace, add a MapInfo TAB (MITAB) reader, browse to the city_parks.tab file that is included in the downloads. Click OK to add the reader.

tabreader.jpg

 

2. Rename Attributes

When we view the attribute names in Google Earth, we don’t want any underscore or any other data specific naming conventions. Add an AttributeRenamer transformer to the canvas. Select name_alt as the Input Attribute and then type “alt name” as the Output Attribute.

 

3. Set KML Properties

We can also control how the attributes appear in the navigation tree in Google Earth as well as the popup description balloons when you click on a feature. Add a KMLPropertySetter to the canvas and connect it to the AttributeRenamer. In the parameters, set up the following:

Name: name

Summary: Park

Attribute Table Title: Park Names

kmlpropsetter-parks.jpg

 

4. Set KML View Regions

Polygons:

The KMLRegionSetter is used to create regions that set Level of Detail bounds within KML. For polygons, the KMLRegionSetter is used to calculate the Region Bounding Box from the Feature Bounding Box, and maximum and minimum display sizes are set. Add a KMLRegionSetter to the canvas, in the parameters set the Minimum Display Size to 20 and the Maximum Display Size to 1000.

polygonregion.jpg

 

Points:

For points, a Region Bounding Box, as well as maximum and minimum display sizes are set using the KMLRegionSetter. Point features produce an infinitely small bounding box and would never show in the output. Therefore, it is better to set a bounding box for point features. Add a CenterPointReplacer to the canvas and connect it to the City_Parks reader feature type. Then add a second KMLRegionSetter and connect it to the CenterPointReplacer.

workflow.jpg

 

Set the following parameters:

Calculate from Feature Bounding Box: No

Minimum Display Size: 5000

Maximum Display Size: -1

Minimum X: -97.7

Minimum Y: 30.2

Maximum X: -97.5

Maximum Y: 30.4

pointregion.jpg

 

5. Write to KML

With the regions set, we can now write to KML. Add a Google KML writer to the canvas. Browse to a location to save the file and name the dataset ParkRegions.kml. Set the Feature Type Definition to Automatic.

kmlwriter.jpg

 

In the Feature Type dialog, set the Feature Type Name to Parks and click OK. Connect the writer feature type to both of the KMLRegionSetters.

 

6. Run the Workspace

Save and run the workspace. Once it has finished running, click on the Parks writer feature type to open the popup menu. On the popup menu, click Open Containing Folder, then double-click on Parks.kml to view the data in Google Earth.

 

The park polygons have the same colors as in the source data. This is due to FME preserving the source styling attributes, fme_color and fme_fill_color attributes.

Zoom in and out to notice the effect of the Minimum and Maximum Display sizes.

Zoomed Out:zoomedout.jpg

 

Zoomed In:

zoomedin.jpg

 

Data Attribution

Data used in this article originates from open data made available by the City of Austin, Texas. It contains data licensed under the Public Domain Dedication License - City of Austin.

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.