Ex4 - 3D data transformation
Introduction
The data used in this exercise is based on open data from the City of Vancouver, Canada.
This exercise asks you to assume the role of a city planner at the city of Vancouver.
A new property development is being planned within the city. The planning department has asked for a 3D visualization of the city elevation model, taking this new development into account.
The task is to read the current elevation model, apply the changes provided by the property developer, and create a three-dimensional output in Adobe PDF format.
Your manager has handed you this task, thinking that it will be very difficult. He doesn't know FME as well as you do!
Objectives
Create a 3D pdf with FME, with certain parameters based on a configuration file.
The config file will define the picture resolution and the topographic exaggeration scale.
Resulting PDF : https://s3.eu-central-1.amazonaws.com/training.insersa.ch/FME/geopython2019/results/SurfaceModel_hd.pdf [18 MD]
Workspace description
Contour lines are read and processed :Here we have two sets of contours lines (new and old). The ChangeDetector transformer will tell us which contours are new in this dataset, which are replacements, and which are the same as before.
Did you notice that the added contours do not have an elevation value set? This is a problem because we can't generate a proper 3D model without elevation! It must be that the labels in the source data are meant to denote the contour elevation (you can use the Data Inspector to open the data and confirm this is so).
Therefore the labels are read and the _NeighborFinder _transformer will transfer the label values onto the nearest contour.
Vancouver is a quite flat city, so why not exaggerate the Z scale a little by using the ExpressionEvaluator.
Having an elevation attribute is fine, but to actually create a 3D model we must convert this into a true Z value. This is done with a _3DForcer _transformer
Now we have 3D contours and we can create our surface model :
And add the texture :
The AppearanceSetter is used to apply the raster as an "appearance" or texture onto the DEM surface. The Raster data is the Appearance and the TINSurface port is the Geometry.
The RasterResampler allows us to reduce the size of the pictures to a more manageable size.
We extrude the building footprints :
And finally export it as a PDF :
You can open the PDF in the output folder.
You may get this initial warning :
Just click :
and after click on
Exercise
This wokspace works fine as it is. But now you would like to send it to people that have never used FME before. Of course, you don't want them to open the workspace and break anything by accident. The solution is to create a external config file, in this case it will be an INI file.
You will add the following parameters to the config file :
- "raster_size" which is a percentage of compression of the inital picture.You may have noticed that the output file is quite big (about 99 MB).
- "vertical_scale" . If Vancouver seems a little flat, then why not exaggerate the Z scale a little to compensate!
1) Create the config file
In the FME project folder (C:\FME_data\Ex4 - 3D data transformation), create a txt file with notepad++ named "config.ini" with the following lines:
[picture]
raster_size = 20
[contours]
vertical_scale = 4
Use Nopepad++ to avoid any encoding issue.2) Create the first scripted parameters
Can create a new parameter this way :
Select Scripted (python)
And as a value enter the folowing code :
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('config.ini')
return config.get('picture', 'raster_size')
Close the two windows.
Now you can go to the RasterResampler transformer and open it up (just double click on it).
In the main window, link the percentage value to the new parameter
The parameter now defines the behaviour of this tranformer.
3) Add the second parameter
The second parameter is the vertical scale factor. We will define it in a slightly different way.
First, double click on the ExpressionEvaluator transformer.
In the Private Parameters panel, click on the
It will open up the same window as before.Select "Scripted (python)" as type, and name the parameter "vertical_scale". Add the following lines as value :
import ConfigParser
config = ConfigParser.RawConfigParser()
config.read('config.ini')
return config.get('contours', 'vertical_scale')
Back to the transformer window, replace the constant "4" with the new parameter as follows :
4) Run the workspace
Run the workspace and play around to see the effect of the parameters.
A scale factor of 20 will really exagerate the topography.
Working with parameters is mainly useful when deploying one workspace in different environments (development env., test env. , User acceptance testing env. production env.). Paths and credentials can be easily adapted to the environment without changing the workspace.
Advanced task
It could be nice if you could add all the input paths as parameters. Furthermore, the output PDF file must be in a folder containing the date of the day.