Counting Vertices and Parsing Coordinates

Evie L
Evie L
  • Updated

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. 

Source1.png

The source dataset for part 2 is a randomly created FME Feature Store dataset containing a polygon. 

Source2.png

Step-By-Step Instructions

Part 1: Lines

1. Create a New Workspace

Open FME Workbench and create a blank workspace. 

NewWorkspace.png

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.

RouteReader.png

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. 

QuickAdd1.png

Connection1.png

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. 

CoordExtract1.png

5. Run Workspace

Connect an Inspector transformer to the CoordinateExtractor's Output port. 

Workspace1.png

Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar. 

Run.png

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. 

Output1.png

Part 2: Polygons

1. Create a New Workspace

Open FME Workbench and create a blank workspace. 

NewWorkspace.png

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.

Reader2.png

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. 

Quickadd2.png

Connection2.png

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.

CoordExtract2.png

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. 

image.png

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. 

ListExplode.png

6. Run Workspace

Connect an Inspector transformer to the Elements output port on the ListExploder. 

 Workspace2.png

Run the workspace by clicking the Run button on the top toolbar, or by selecting Run > Run Workspace from the top menu bar. 

Run.png

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. 

Output2.png

Data Attribution

The data used in this tutorial originates from Safe Software

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.