Files
-
- 200 KB
- Download
Introduction
Although FME can create cartographic elements, such as labels, it is not intended for cartographic use. In this tutorial, you will learn how to create labels for point features and how to create a center point in polygons, which can then be converted to a label point.
Data Source
Source
The source for part 1 is an Esri Shapefile containing point locations for schools in the City of Vancouver.
The source for part 2 is an Esri Geodatabase containing neighborhood polygons for the City of Vancouver.
Step-by-step Instructions
Exercise 1: Labeling Point Features
In this scenario, you want to create labels for school point features.
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an Esri Shapefile Reader
Add an Esri Shapefile reader to the canvas by clicking on the Reader button on the top menu bar or by going to Readers > Add Reader. In the Add Reader dialog, select Esri Shapefile as the Format, then for Dataset, browse to the Schools.shp dataset, which is available for download from the Files section on this article.
3. Label Points
Click on the Schools reader feature type to select it. Then add a LabelPointReplacer transformer to the canvas by typing “LabelPointReplacer” to bring up the list of FME Transformers in the Quick Add Search. Select the LabelPointReplacer from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it.
Double-click on the LabelPointReplacer to open the parameters. In the parameters, set the Label to school_name, then set the Label Height to 50.
Note: Label height is measured in ground units (meters in this case) and may be entered as a number or taken from the value of a feature attribute by selecting the attribute name from the drop-down list. If the label height is too tall, you can either adjust the label height accordingly in the LabelPointReplacer parameters or edit the annotation size in the output format.
4. Run Workspace
Add an Inspector to the canvas and connect it to the LabelPointReplacer LabelPoint output port.
Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar.
After running the workspace, in the Visual Preview, labels will appear next to each point feature.
Exercise 2: Labelling Polygon Features
In this scenario, you want to create labels for neighborhood polygon features that can be exported.
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an Esri Geodatabase (Open API Geodb) Reader
Add an Esri Geodatabase (Open API Geodb) reader to the canvas by clicking on the Reader button on the top menu bar or by going to Readers > Add Reader. In the Add Reader dialog, select Esri Geodatabase (Open API Geodb) as the Format, then for Dataset, browse to the Neighborhoods.gdb dataset, which is available for download from the Files section of this article.
3. Find Center Point
Before we can label the neighborhood polygon, we need to define a location to attach the label; in this case, the polygon's center point. Click on the Neighborhoods reader feature type to select it. Then add a CenterPointExtractor transformer to the canvas by typing “CenterPointExtractor” to bring up the list of FME Transformers in the Quick Add Search. Select the LabelPointReplacer from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. There are no parameters to set.
4. Label Points
With the center points defined, a label can be attached. Add a LabelPointReplacer to the canvas and connect it to the CenterPointReplacer. In the parameters, set the Label to NeighborhoodName, then set the Label Height to 200.
Label height is measured in ground units (meters in this case) and may be entered as a number or taken from a feature attribute by selecting the attribute name from the drop-down list. If the label height is too tall, you can either adjust the label height accordingly in the LabelPointReplacer parameters or edit the annotation size in the output format.
5. Run Workspace
Add an Inspector to the canvas and connect it to the LabelPointReplacer LabelPoint output port.
Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar.
After running the workspace, in Data Preview (formerly Visual Preview), labels will appear next to each point feature in the center of each neighborhood polygon.
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.