Build Road Lines from GPS Points (CSV to Esri Shapefile)

Liz Sanderson
Liz Sanderson
  • Updated

FME Version

Introduction

In this translation, we will take some tabular CSV data, representing points along a road, connect the points to create lines, join some attribute data to the lines from an access file and write the roads out to an Esri Shapefile.

Let's take a closer look at our source data. Many users work with spatial data in a delimited text format of some form, such as a CSV file like we have in this example.

This file contains GPS points representing surveyed roads; each record holds a road ID value, vertex number and XY coordinates for each point. The road ID is a unique identifier for each road so, these 12 records with Road ID equals 1, represent one road. We also have some road attributes in an Access file. Notice that there is also a road ID column in this table; we will use this key attribute to join these road attributes onto our lines during the translation.

View of the GPS point data in a CSV file

 

Video

Note: This video was created with FME 2015, the concepts are similar but the user interface will be different. In this demo, we'll set up a workflow to automatically import a CSV file of GPS data, convert it to GIS points and lines, join with a Microsoft Access file to get further attribute data, then write out to Esri Shapefile. You'll see how to control the output schema and clean up the attributes.

 

Step-by-step Instructions

1. Add Reader

Let's get started by opening a blank workspace in FME Workbench. Add a CSV reader to the canvas and open up the Roads.csv dataset. View the parameters of the CSV file to confirm that FME has picked up the schema correctly. This data is in the City of Austin, Texas so we need to set up the coordinate system. For Coord. System enter TX83-CF and click OK to add the reader.

CSV Reader parameters, change the data type to x and y_coordinate

 

2. Create points with the VertexCreator

Add a VertexCreator to the canvas. In the parameters, set the X Value to x and the Y Value to y. Ensure that the Mode is set to Add Point.

 

3. Create lines with the LineBuilder

Place a LineBuilder transformer on the canvas; if we just ran the workspace without setting any LineBuilder parameters, we would get one messy looking line. We need to set the connection break attribute. Remember that the road ID is what uniquely represents each road; set this as the connection break attribute.

LineBuilder parameters, set the Connection Break Attributes to road_id

 

4. Join the data to an MS Access file containing attribute details

Now let's read in the roads_attrs.mdb MS Access file containing road attributes using the DatabseJoiner transformer, connect the DatabaseJoiner to the Lines Output port on the LineBuilder. In the parameters, read in the MS Access file and set the table to major_roads. Then for Feature Attribute set it to the road_id attribute and set the Table Field to ROAD_ID. For Fields to Add, click on the ellipsis, then select all of the features. The rest of the default values are good, click ok.

DatabaseJoiner, join on road_id and ROAD_ID

 

5. Write to Shapefile

Let's add a Shapefile writer, and then select automatic… for the definition. Browse to a folder to save the Shapefile to, then click ok. In the next dialog, enter Roads for the Shapefile Name, and set the Geometry to shape_polyline. Click ok and connect it to the Joined Output port on the DatabaseJoiner.

In the Shapefile Writer parameters, change the Shapefile Name to Roads, and the Geometry to shae_polyline

 

6. Clean up attributes and run translation

As soon as we connect it up with the DatabseJoiner, notice that the attributes are automatically populated based on what the destination feature type is connected to. Now, we really just want to see the attribute from the MS Access file in our final output so let's clean up the destination attributes. Double-click on the Shapefile writer to open the Destination Feature Type Properties and in the User Attributes tab click on Manual for the attribute definition; this allows us to edit the schema. Remove road_id, vertex_num, x and y; these came from the CSV file. Run the workspace and view the output.

 

Data Attribution

Data provided by the City of Austin and Travis County, Texas

Was this article helpful?

Comments

0 comments

Please sign in to leave a comment.