In this tutorial we will translate some DGN data, representing city traffic lights, to Esri Shapefile.
The traffic lights are represented by DGN cells; since the shape format does not support
the concept of cells, we will convert them to points and make the text next to the traffic
signal an attribute of the points.
Let's take a look at our DGN data in the FME Data Inspector. We will open it using the
Bentley MicroStation Design V8 reader then, for the data set, select trafficsignals.DGN file.
If we just clicked OK then FME would use the level number in the DGN file as the feature type name.
However, we know that there is also a level name in the DGN data and usually
it's more intuitive to work with level names, rather than numbers.
So, let's view the data again; this time, we will set up the reader to read the level
names. We will go into the parameters and set the "Group Elements By" to "Level Names".
We can also set up the reader to read the insert points of the traffic signal
cells, rather than the cells. Under Element Options, expand the "Named Cells" option
then check "Preserver Name Cell Insert Points". Click OK. We can see that, on the traffic
signals level, we have the insertion point for the cell and the signal text. Let's get
working with this in FME Workbench.
We have set our reader format and data set to read the traffic signals just as we did
in the Data Inspector. We will set up the reader parameters to read the level names
and the cells as points.
We have also set our writer format to Esri Shape and selected our output location for
the data set. We are only interested in the traffic signals feature type so, within the
select feature types dialog window, we will uncheck "Default".
As you can see FME workbench automatically places a geometry filter on the canvas to
separate the points from the text; this is because the shape format does not allow multiple
geometries per file. Remember, our goal is to write points and to merge text onto the
points as an attribute. So we will delete the text output feature type.
We will use a neighbour finder transformer, to convert the text onto the points the neighbour
finder transformer finds the closest candidate feature within a specific maximum distance
of each base feature. We want each base point to find one text candidate within a certain
distance but you may be asking what should this distance be???
We can use the FME Data Inspector to quickly do a rough measurement, by selecting the ruler
tool and dragging a line between the two points. We can see that the distance appears to be
just over 2 meters.
Back in FME Workbench, within the neighbour finder parameters, we can set the maximum
distance using the measurement we just took. Let's round this number to 3 meters. If we
inspect the data at this point, we will see that FME has put the DGN text into an attribute
called FME_text_string.
Back in FME Workbench we will use an attribute renamer to change the name to simply be "text".
Within the parameters we can enter our original attribute name followed by the new one that
we wish to apply. We also need to make sure that the destination shape file as han attribute
called "text", which we can do within the user attributes; a width of 10 should
be sufficient.
Now we will run the workspace by clicking on the green play button.
A quick inspection of the data shows us that we indeed have points in our shape file and
that there is a new attribute called, text.