Writing GPX Data

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

  • FME 2018.x

Introduction

When writing to the GPS eXchange Format (GPX) format, certain attribute names need to be set using the schema in the documentation. Using the correct schema format ensures that the attributes are written correctly and the data you require while you are in the field is available. It is important to note that data written to the GPX format will be automatically reprojected in the writer to decimal degrees (WGS84 datum) which is the EPSG:4326 coordinate system. For information 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 that each have their 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 take the data that has been written 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, this 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 now 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

Transformers AttributeManager 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 rest of the 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 will be a good idea to set the metadata on the GPX file so that the field technician will know who to talk to if something isn’t correct 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 make the date match 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?

Comments

0 comments

Please sign in to leave a comment.