Streaming GeoJSON with FME Flow

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

The GeoJSON format provides a way to communicate location data as part of the open JSON (JavaScript Object Notation) specification. The Data Streaming Service in FME Flow (formerly FME Server) allows users to easily incorporate this data into a web service.

The example below demonstrates how we can use FME Workbench to produce a string of GeoJSON, which once published to FME Flow can be used to generate a Direct URL to link the data to an external web service. The second part of the tutorial shows the reverse - how to look ‘behind the scenes’ of the web service to find the basic syntax used in this data request.

 

Step-by-step Instructions

1. Create an FME Workspace

Open FME Workbench and select Generate Workspace. Read in the data that you wish to serve and set the writer dataset to GeoJSON format. Optionally, you can use the example workspace found in the Files section of this article that uses an SDF data source detailing bus routes and bus stops in Austin, Texas.

image.png

Note: Be aware you may need to re-project the data depending on the client application. In our example, the data has been reprojected to EPSG:4326 for use in OpenLayers.

 

The Transit SDF dataset contains two feature types, bus routes and bus stops. If your dataset is formed of multiple layers (feature types) you can set up a published parameter where the user can request to stream one or many layers. For testing purposes, you can select a single layer to read by going into the reader parameters in the Navigator window and setting the Feature Types to Read.

image.png


2. Publish the workspace to FME Flow

Go to File and select Publish to FME Flow. In the Publish Workspace window, make sure you’re connected to FME Flow, create or choose a Repository to save the workspace in, and also ensure the Upload data files box is checked.
image.png

Register the workspace with the Data Streaming Service, select the edit button here to explore the different options, and make sure the GeoJSON file has been selected as the writer to stream.

image.png

 

3. Run the Workspace on FME Flow

Go to the FME Flow Web Interface and navigate to Run Workspace. Select the repository and workspace you just published. Run the workspace, and the GeoJSON will be returned and download from your browser.
image.png
image.png

FME Flow will return the GeoJSON MIME type in the response header as well the Content-Type; in this case, application/json.

 

4. Request data using Webhook URL

Return to the Run Workspace page and expose the Advanced section. This section includes a link to create a Webhook URL that can be used directly within a web service to request the GeoJSON. Click the link to open a page to configure the Webhook.

image.png

 

5. Configure the Webhook URL

The page that opens will let you create an API Token to allow authenticated access to the Webhook URL. You can configure how long the token will be valid for using the Expiration parameter. If you expand the Parameters section and change the value of the Feature Types to Read parameter, you will see the change reflected in the parameter syntax of the URL.

image.png

The Direct URL obtained above can be provided to any client application that consumes GeoJSON. FME Flow will dynamically return the data in GeoJSON when the URL is invoked. 

The OGC Web Feature Service (WFS) is supported by FME Flow and has the ability to return features with spatial geometry like the examples covered in this article. For detailed instructions, see How to Create a WFS Service Using FME Flow. You may also want to incorporate the data streaming service into an FME Flow App.

Alternatively, you may be interested in streaming other data formats, in which case this article may be of interest: Streaming XML with FME Flow.
 

Data Attribution

Data used in this article originates from open data made available by the City of Austin, Texas. It contains data licensed under the Public Domain Dedication License - City of Austin.

 

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.