Exercise 03: Working with CityGML

The goals of this exercise are to familiarise yourselves with CityGML and how the UML models and data schema translate into 3D models. For visualisation of CityGML models, FME (Feature Manipulation Engine) by Safe software is used. Each of you would have already applied for and received an FME Education License as instructed on Moodle.

The first part of the documentation is an introduction to FME interface, and the second part is a step-by-step process of building and running a workbench where you will work with CityGML data and learn how it can be converted to different data formats for compact data sharing and visualisation.

Once you are done with this exercise, you would have learnt these key points.

  1. Working with CityGML files and understanding how the UML diagrams can be mapped to concrete 3D models.

  2. Enriching CityGML models with textures, external 3D models and additional attribute information of the environment.

  3. Using transformers within FME to edit, manipulate data to harmonize different datasets to suit the needs of you application and to export/share the CityGML models in various formats.

  4. Exporting to the 3DCityDB schema using the importer/exporter tool via command line.

  5. Exporting from 3DCityDB to web-visualisation and 3D tiles.

Exercise Tasks

This is again a group work. You will be assigned to a group and each group will work with one quadrant of the TUM dataset that is assigned to you.

For a successful exercise, you must perform the following tasks (A, B and C), get your final CityGML dataset (with all the components) and push it to the 3DCityDB. In the last stage of the exercise, we (the tutors) will push the models created and uploaded by you to 3D tiles and visualise it on a web-based platform. This is to reinforce how the concept of CityGML (that you learnt in the lectures) can be translated onto various platforms, thereby serving so many diverse applications.

What is expected at the end of the exercise?

As you go through the tasks, you will also find a few questions which need to be answered by you. Please add the answers to a notepad/doc/pdf file and submit it to Moodle along with the folder containing your final dataset and the FME WorkFlow.

Task Set: Working with CityGML in FME

Most of you are familiar with FME already. If you are not, please check the FME - Feature Manipulation Engine. You would have to use FME transformers to complete the tasks.

Info

  • You have 45 minutes to divide and conquer the sub-tasks.

  • In case of any doubts regarding the transformers, either refer to FME’s official website or ask the tutors. Hints (for possibly useful transformers) are provided for each sub-task throughout the documentation. Each Transformers has a specific configuration of parameters that you must test and adjust to your task. Please carefully check them!

Before you start please check the data provided to you and the data you need to find and download by yourself. The task filled with green are provided and the unfilled tasks are required and need to be downloaded by you.

  1. A base dataset of the Quadrant in CityGML LoD2 [adapted from the standardised open data downloaded from LDBV open data portal]: <XX_TUM-xx_Quadrant.gml>

  2. A street space model of the area around the TUM Campus in CityGML: TUM_Streets_CityGMLv2.gml

  3. A tree cadastre model for the area around TUM in CityGML: TUM_SolitaryVegObjects_MUC_IOER2019.gml

  4. CSV List of LoD3 buildings present in the TUM2Twin Dataset

  5. LoD3 Building of the TUM Campus - TUM2TWIN dataset [This data can also be downloaded directly from the given website also]

  6. High-Resolution Aerial Images from Bayern Open Data Portal [This data needs to be downloaded by each group].

Important

Before you start off on your sub-tasks - Open all your datasets (that have spatial characteristic) in “FME Data Inspector” and really inspect the dataset. Please check if all your data is in the same coordinate system and aligned on the same level. There could always be variations which will cause problems later. The expected coordinate Reference system of your final dataset is “EPSG: 25832” which refers to “ETRS 89 - UTM Zone 32N”. This is important, otherwise importing the dataset to the Database will fail.

Hint

  • When converting from Gauss-Kruger to UTM (if necessary), a z-offset of -46.5 is required to align the models. You can use the FME Transformer offsetter for this purpose.

Note

  • All ETL processes (like the FME workflow) have an input (Readers in FME), Transformers, and Output (Writers).

In this sub-task, you need to evaluate the LoD2 and LoD3 datasets. Replace the LoD2 buildings with LoD3 models where available. (Not all LoD2 buildings have LoD3 counterparts). Once all the building models (LoD2 and LoD3 where available) are combined, apply the styling mentioned in the last point in this task. The logic of the workflow is given here along with hints.

Consider the LoD2 Model dataset as ‘Set A’ and the LoD3 Models as ‘Set B’.

  • Use the CSV file (with the gmlid and gml_parent_id) to extract all the buildings from the LoD2 dataset which do not match the LoD3 models in the CityGML_LoD3_folder i.e., your are leaving out the LoD2 models for which there is a corresponding LoD3 model in the dataset.

    Hint: Match the gml_id of the LoD2 models to the LoD3 models. You can try using the FeatureMerger Transformer.

  • Replace the left-out LoD2 models with the LoD3 models. Use the same logic as above. Match the gml_id of the LoD3 buildings (which were used in the previous step) from the csv with the full CityGML LoD3 model.

    Hint: Use another FeatureMerger transformer to identify the building models with the gml_ids in your quadrant. Since you only need the buildings that have a corresponding model in your previous step, connect the “UsedSupplier” output from the first FeatureMerger to the FeatureMerger_2. This will give you all the buildings and the walls.

  • Since the LoD3 models also have the openings (windows and doors) and these do not have corresponding entities in the LoD2 dataset, they need to be extracted from the LoD3 dataset by using the walls (which are the parents of the openings).

    Hint: Use another FeatureMerger - FeatureMerger_3 - to match the gml_parent_id of the windows and doors (requestor) to the ‘gml_id’ of the geometries merged in the previous step.

  • But now, you see that all the features are bundled into a single output unit. These need to be separated back into the layers that we had from the input (reader).

    Hint: Use the FeatureTypeFilter to get back all the individual layers.

  • Set Appearance to the Building Models. Roofs need to be ‘Red’ (HEX-#aa0000), Walls need to be ‘Light Grey’ (HEX-#efebdb) and Openings (Windows and Doors) need to be ‘Black’ (HEX-#000000).

  • Export the combined dataset using the “OGC CityGML” writer.

    Hint: When writing out the data, choose to create the writer “Feature Type Definition” = “Copy from Reader”

Task B1 - In this sub-task, you need to apply textures from the High-res Aerial Images to the street spaces. You only need to do this for the streets in your Quadrant, not the full dataset. The logic of the task is as follows.

  • Get the bounding box of your Quadrant from the LoD2 base dataset and clip the streets.

    Hint: Try using the BoundingBoxAccumulator and Clipper transformers.

  • Import the 20cm GeoTiff Aerial Orthophotos downloaded from the Bayern Open Data Portal. The Tiles from the open data do not exactly align with the quadrant of the TUM base dataset - hence - mosaic them to have one complete uninterrupted aerial image.

    Hint: You can use the Mosaicker transformer here.

  • Clip the Aerial photo to the streets (clipped to the quadrant extents).

    Hint: Use the Clipper tool again.

  • Set Appearance to the streets using the clipped Aerial photos as the “Appearance” and the the clipped streets as the “Geometry”.

    Hint: Use the AppearanceSetter transformer here.

  • Additionally, you can also group the appearance by ‘gml_id’. This will make sure that every street segment with a unique gml_id has its attached appearance.

    Hint: Use the AttributeKeeper after Clipper and select “gml_id”. When setting appearance in the AppearanceSetter, choose to group by the gml_id.

Task B2 - In this sub-task, you need to clip the vegetation dataset to your Quadrant extent and then apply appearance to your trees

  • The tree appearance needs to be in ‘green’ (HEX-#55aa7f).

    Hint: You can follow a similar procedure to the one explained in sub-tasks B1.

  • Export the combined dataset using the “OGC CityGML” writer.

    Hint: When writing out the data, choose to create the writer “Feature Type Definition” = “Copy from Reader”

Important

Once you are done with the sub-tasks A and B - Please combine both the CityGML Files (Buildings and StreetSpace + Vegetation into a single file) i.e., in the end every group must have a single CityGML file that consists of the LoD2, LoD3 buildings, street spaces and Vegetation.

Create a CityDB instance with Docker and Import

  1. **PAY ATTENTION TO THE “INTRODUCTION TO DOCKER” SLIDES presented in the exercise.

  2. Download and install Docker from the link provided in the Moodle Announcement on 30.06.2025

How do you speak to docker??

Please use the Window Powershell / Command line Terminal to command Docker once it is installed.

#Create the 3DCityDB Instance - Change the details in <..> as per your system!!!!
docker run -d -p <Portnumber:5432> --name <name_of_the_container> -e POSTGRES_DB=citydbv5 -e POSTGRES_USER= <user_name> -e POSTGRES_PASSWORD= <user_password> -e SRID=25832 3dcitydb/3dcitydb-pg
  1. Download pg-admin from here

  2. Use the details (used in the docker instance) to create/login to the server to check if your database is created with all the required tables. Please click and explore the server that is created.

  3. Please import the CityGML file into the 3DCityDB - CityGML mapped onto Spatial Relational Databases which we will look at in the upcoming lectures - using the following CLI command. A detailed documentation of about the 3DCityDB is available here. We are using the citydb-tool v1.0.0 here which is available on the github-repository

  4. Use the following command to import into the database you created!

#Import Data into the database you have created now - Change the details in the command as per your system!!!
citydb import citygml -P <Portnumber> -d citydbv5 -u <user_name> -p <user_password> folder/filename.gml

How do you actually use the citydb-tool??

  • Download the citydb-tool-1.0.0.zip from the above github repository. Unzip it.

  • Open the commandline from the folder by typing in “cmd” in the folder location bar. This will open the command line with that directory. Copy and paste the above code in the commandline interface. DO NOT forget to adapt the path to your final CityGML in the last line of the code!

Submission

Please submit the following as a .zip folder. One submission per group is enough. Please also include as .txt file with the full names of the group members in the folder.

  1. The FME Workflow(s) created

  2. The presentation answering the questions presented on 01.07.2025

  3. The final CityGML model including all Buildings, street spaces, vegetation along with their textures.

  4. A text file containing the names of the group members