Writing GPX Data

Liz Sanderson
Liz Sanderson
  • Updated

Introduction

When writing to the GPS eXchange Format (GPX) format, certain attribute names must be set according to the schema outlined in the documentation. Using the correct schema format ensures that the attributes are written correctly and that the data you require while in the field is available. It is essential to note that data written to the GPX format will be automatically reprojected by the writer to decimal degrees (WGS84 datum), which corresponds to the EPSG:4326 coordinate system. For information on how to read GPX data, see the Reading GPX Data article.

GPX Overview

When adding a GPX Writer to the canvas, six feature types are available to write to, each of which has its own purpose.

  • Metadata: The metadata contains the details about the author and copyright information
  • WayPoint: Particular points along a route, when following a GPS route, these are the main points you would pass over.
  • Route: The intended path of travel
  • Route Point: Points along the path of travel; there may be more route points than waypoints.
  • Track: While in the field, this is the path of actual travel
  • Track Point: The points along the track while following the waypoints.

Step-by-step Instructions

In this scenario, you work for a power company, and you have been asked to create a GPS route for the field technician to walk the transmission lines after a massive wind storm on Salt Spring Island, British Columbia. The field technician will convert the data into GPX format and input it into their GPS device. You have the data in Shapefile format, but the attributes will need to be cleaned up before writing out to GPX.

1. Open FME Workbench

In a blank FME Workbench canvas, add a Shapefile reader. In the reader parameters, set the Dataset to Transformers.shp, which is the file containing the power poles of interest along the route.

Transformers.shp viewed in the FME Data Inspector. Background map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Next, add another Shapefile reader, and read in the PowerLines.shp; this is the file containing the power lines that connect to the power poles. The power lines in this file have been generalized so that there is only one line instead of four.

PowerLines.shp viewed in the FME Data Inspector. Background map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

2. Create WayPoint Attributes

Now that the data has been read in, we can prepare the attributes before writing out the data. When working with data to write out to GPX, it is important to have the documentation open so that you can refer to the attribute naming schema. To set the waypoint attributes, add an AttributeManager transformer to the canvas and connect it to the Transformers Shapefile feature type. In the AttributeManger parameters, set the following attribute names:

Input Attribute Output Attribute
ID name
OWNER source
DATE_INSP creation_time
CONDITION comment

3. Add GPX Writer

Add a GPS eXchange Format (GPX) writer to the canvas, name the file WindStormPath.gpx, and click ok. When the Select Feature Types dialog appears, select all and click ok.

Connect AttributeManager to the WayPoint feature type.

1548100819243.png

The Transformers AttributeManager is connected to the WayPoint feature type from the GPX writer.

4. Create Route Attributes

Next, we will create the Route attributes. Add another AttributeManager to the canvas and connect it to the PowerLines feature type. In the parameters, set the following attribute names:

Input Attribute Output Attribute
CIRC_DESC name
OWNER source
TRNSMSS_ID route_id

The remaining attributes can be removed. (SOURCE_DT, VOLTAGE, ANNO_CAD, OBJECTID, FEAT_LEN)

Now connect the AttributeManager_2 to the Route feature type.

route.png

PowerLines AttributeManager connected to the Route feature type from the GPX writer.

5. Create Metadata

At this point, the workspace can be run, and the GPX file can be handed off. However, the GIS department at the power company is rather large. It would be a good idea to set the metadata on the GPX file so that the field technician knows who to contact if something is incorrect or they would like something changed.

First, we will want to set the date for when this data is created. Add a Creator transformer, then add a DateTimeStamper transformer to the canvas. In the DateTimeStamper parameters, set the Type to Date and click ok. Next, add a DateTimeConverter and connect it to the DateTimeStamper. We will use the DateTimeConverter to ensure the date conforms to the ISO standard. In the parameters, set the output format to:

%Y-%m-%d (ISO Date)

Now, to set the attributes, add an AttributeCreator to the canvas and connect it to the DateTimeConverter. In the parameters set the following:

New Attribute Attribute Value
name John Smith (or your name)
description For line inspection after 10/10/2018 wind storm
creation_time _timestamp
author_email example@example.com (or your email)

For creation_time, _timestamp is the attribute that was created with the DateTimeConverter

Finally, connect the AttributeCreator to the Metadata feature type.

metadata.png

Metadata attributes created and connected to the Metadata feature type from the GPX writer.

6. Run the Workspace

For this scenario, we are only using the Waypoint, Route, and Metadata feature types; the other three feature types can be deleted if desired (RoutePoint, Track, and TrackPoint).

Run the workspace and inspect the outputs. Ensure that you have attribute values for each of the attributes set above. If some attributes are missing that were intentionally set, double-check capitalization and spelling, as this writer relies on the correct schema.

Output WindStormPath.gpx viewed in the FME Data Inspector. Background map tiles by Stamen Design, under CC BY 3.0. Data by OpenStreetMap, under ODbL.

Data Attribution

Power line data from Data BC - British Columbia Government

Power pole data randomly generated

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.