Files
-
- 300 KB
- Download
Introduction
In this article, we will transform non-spatial (tabular) data from a CSV file (.csv) into a spatial dataset in the Esri shapefile (.shp) format. By the end of this tutorial, you will have a shapefile containing spatial point features representing each cell signal measurement.
Step-by-step Instructions
1. Start FME Workbench and Add a CSV Reader
As of FME 2025.2, the Coordinate System parameter is now configured within the Parameters dialog of each reader/writer format. For more information, including details about the change and affected transformers, please see Coordinate System Parameter Location Change.
-
In a blank workspace, click the Add Reader icon and add a reader with the following parameters:
Format: CSV (Comma Separated Value)
Dataset: /CellSignals-Small.csv
Click the Parameters button to set the coordinate system:
Feature Type Name(s): From File Name(s)
This shows the file name on the canvas, which is useful when adding multiple datasets
Attribute Definition: Manual
Name: longitude
Type: x_coordinate
Name: latitude
Type: y_coordinate
Create Point Geometry from Attributes: Enabled
X Coordinate Attribute: longitude
Y Coordinate Attribute: latitude
Coordinate System: LL84
Click OK to add the reader to the workspace.
-
In a blank workspace, click the Add Reader icon and add a reader with the following parameters:
Format: CSV (Comma Separated Value)
Dataset: /CellSignals-Small.csv
Coordinate System: LL84
Open the Parameters and set the Feature Type Name:
Feature Type Name(s): From File Name(s)
◦ This shows the file name on the canvas, which is useful when adding multiple datasets
Confirm that the longitude and latitude attributes are set to x_coordinate and y_coordinate, respectively. If they are not, change the Attribute Definition to Manual, then manually set.
Click OK to add the reader to the workspace.
2. Verify the data in Visual Preview
Let's confirm that the points we created are being read correctly. Click the reader feature type and click View Source Data from the mini menu.
In Visual Preview, if the CSV Types are set up correctly, you should see point data in the Graphics View window.
Turn on Background Maps to ensure that the coordinate system is set up. To do this in Visual Preview, if your window is small, click the >> to expand it, then click Background Map Off. In the Background Map drop-down, select a new background map or a pre-saved one.
If you have a background map enabled, but you do not see it behind your points, this means the coordinate system was not set up in the reader. You can fix this by finding the CSV file in the Navigator pane, expanding it, and then opening the Coordinate System and setting it to LL84.
3. Set up a Shapefile Writer
Add a writer to the canvas. In the Add Writer dialog:
- Format: Esri Shapefile
- Dataset: Choose a folder location for the output
- Feature Type Definition: Copy from Reader
Click OK to confirm.
4. Connect the Reader to the Writer and Map Truncated Attributes
Connect the source feature type (CSV) to the destination feature type (shapefile).
Now, even though the writer is connected, not all the attributes are mapped, as indicated by the red drop-down arrow. If you expand both the reader and the writer by clicking on the small arrow next to the name, you will see two attributes (num_mesaures and recorded_Tstamp) that are not green.
These attributes are not green because they haven’t been properly mapped, as the shapefile writer truncated their names. This is because the shapefile format has a 10-character limit for attribute names.
To fix this, connect the attributes by clicking the yellow triangle on num_mesaures and dragging the line to the red triangle on num_measur, they should both turn green. Repeat this for recorded_Tstamp.
5. Modify Output Shapefile Writer Feature Type Properties
With the attributes mapped correctly, we have one last thing to do. Open the CellSignal-Small writer feature type parameters by double-clicking on the writer.
In FME 2025.1 or newer, switch to the User Attributes tab:
-
Spatial Definition:
- Geometry Type: shapefile_point
Then click OK.
As of FME 2025.1, the Geometry parameter in Reader and Writer feature types is now configured within the Spatial or Geometry Definition Table under the User Attributes tab. For more information, including details about the change, please see Introducing Spatial and Geometry Definition Tables.
In FME 2025.0 and older, in the Parameters tab:
- Geometry: shapefile_point
Then click OK.
6. Run the Workspace
Run the workspace by clicking the green play button in the toolbar to perform the translation. Once the workspace has been completed, a Translation was SUCCESSFUL message will appear in the Translation Log.
Data Attribution
The data used here originates from open data made available by the City of Vancouver, British Columbia. It contains information licensed under the Open Government License - Vancouver.