In this tutorial we will perform a very common transformation, taking non spatial
data in a CSV file and writing it out to a special format, in this case Esri shape.
Our CSV file lists cellphone signal measurements at various locations in the
City of Vancouver.
We have longitude,
latitude, elevation, station ID, power and quality columns.
Let's create the workspace by opening FME Workbench.
We'll select blank workspace in the Getting Started window.
Drag the CSV file onto the canvas from Windows Explorer.
In the add reader dialog, click on parameters to see how work bench will
read this data.
There is a file preview and a schema attributes section that show how FME
will read the data. The schema attributes section specifically shows which data
types FME will map the columns to; by default a number data type is used for
longitude, latitude and elevation columns but we can map them to XY and Z
coordinate columns so that FME will create points when the data is read.
Click OK to dismiss the parameters. Set the coordinate system as longitude/latitude.
After you click OK, a CSV feature type will be added to the canvas.
Before we add a writer,
let's confirm that the points really are created as the data is read.
Right click on the CSV feature type and select Connect inspector. Run the workspace and
it will open in the FME Data Inspector.
Here we see that we do in fact have multiple points.
Now it's time to add an Esri Shape writer to our workspace but first
let's remove that inspector from our canvas by highlighting it with our
mouse cursor and hitting delete on our keyboard. From the writers menu
select Add writer, enter ESRI Shape for the format, open the folder browser
next to dataset
and select a folder in which to write the shape file.
We will stick with the default, copy from reader, for the shape file definition. Click OK.
Go ahead and connect the source feature type to the destination feature type.
Expand the
attribute list to confirm the proper attribute names were added;
notice that num_measures and recorded _tstamp are not
properly mapped because the Shape Writer truncated their names on the destination;
this is because the shape format has a ten character limit for the attribute
names.
Expand the attributes on the source feature type.
Connect the num_measures
and recorded_tstamp to the truncated ones on the destination.
Open
the destination feature type properties;
let's change the name of the shape file to CellData.
Change allowed geometries, geometry, to shape_point,
then click OK.
Run the workspace by clicking on the green play button.
Right click on the output
and choose inspect to open the newly-created shape in the FME Data Inspector.