Files
-
- 40 KB
- Download
Introduction
The VertexCounter extracts the total number of a feature's vertices and stores the result in an attribute. The CoordinateExtractor transformer retrieves your coordinate values based on the projection or coordinate system used to store the data. In this tutorial, we will go over how to use these transformers with line and polygon datasets.
Source Data
The source dataset for part 1 is a manually created FME Feature Store dataset containing four points that form a route.
The source dataset for part 2 is a randomly created FME Feature Store dataset containing a polygon.
Step-By-Step Instructions
Part 1: Lines
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an FME Feature Store (FFS) Reader
Add an FME Feature Store (FFS) 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 FME Feature Store (FFS) as the Format, then for Dataset browse to the Route.ffs dataset, which is available for download from the Files section of this article. Then click OK to finish adding the reader.
3. Count Vertices
Click on the Route reader feature type to select it. Then add a VertexCounter transformer to the canvas by typing “VertexCounter” to bring up the list of FME Transformers in the Quick Add Search. Select the VertexCounter from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. We can accept the default parameters.
4. Extract Coordinates
Next, add a CoordinateExtractor to the canvas and connect it to the VertexCounter. Double-click on the CoordinateExtractor to open the parameters. In the parameters, set Mode to Specify Coordinate; this will create attributes for x, y, and z coordinates.
5. Run Workspace
Connect an Inspector transformer to the CoordinateExtractor's 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, the output will be opened in Visual Preview. In Visual Preview, each of the vertices will have its x and y values extracted, as well as a count of how many vertices are in each line.
Part 2: Polygons
1. Create a New Workspace
Open FME Workbench and create a blank workspace.
2. Add an FME Feature Store (FFS) Reader
Add an FME Feature Store (FFS) 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 FME Feature Store (FFS) as the Format, then, for Dataset, browse to the coquitlam.ffs dataset, available for download from the Files section of this article. Then click OK to finish adding the reader.
3. Count Vertices
Click on the Coquitlam reader feature type to select it. Then add a VertexCounter transformer to the canvas by typing “VertexCounter” to bring up the list of FME Transformers in the Quick Add Search. Select the VertexCounter from the list of Transformers by double-clicking or by using the arrow keys and the Enter key to add it. We can accept the default parameters.
4. Extract Coordinates
Next, add a CoordinateExtractor to the canvas and connect it to the VertexCounter. Double-click on the CoordinateExtractor to open the parameters. In the parameters, set the Mode to All Coordinates and leave the rest at their defaults. This will create a list attribute on the output feature(s), called _indices, containing the coordinates of each polygon vertex.
5. List Management
The output of the CoordinateExtractor in this Mode outputs a list called _indices, which will appear in the Feature Information window inside of Visual Preview. For more information on lists, see the Tutorial: Getting Started with List Attributes article.
Add a ListExploder to the canvas and connect it to the CoordinateExtractor Output port. In the parameters, set the List Attribute to _indices{}. This transformer will make each list object into its own feature.
6. Run Workspace
Connect an Inspector transformer to the Elements output port on the ListExploder.
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, the output will be opened in Visual Preview. In Visual Preview, each vertex will have its x and y values extracted, along with a count of the number of vertices in the polygon.
Data Attribution
The data used in this tutorial originates from Safe Software.