Working with 3DCityDB Series
Importing CityGML into 3DCityDB with PostgreSQL
Photo by Syed Hussaini on Unsplash

In the previous part, we successfully set up an empty 3DCityDB schema inside PostgreSQL with PostGIS. At this stage, the database structure exists — but it’s still empty.

Link to previous parts —

In this part, we’ll bring the city to life.

We’ll use the 3DCityDB Importer/Exporter Tool to import a real CityGML dataset (Berlin LoD2 buildings) into our database and verify that everything has been stored correctly.

By the end of this section, you’ll know:

If you want to understand how to install the required software for 3DCityDB, please follow Part 2 of this series.

Let’s begin importing 3D cityGML data….

Step 1: Launch the Importer/Exporter Tool

Start by opening the Importer/Exporter Tool:

Importer/Exporter shortcut on desktop
Importer/Exporter Tool User Interface
Go to the Database tab

Once the tool opens, you’ll see a multi-tab interface. Everything related to database connectivity happens in the Database tab — that’s where we start.

Step 2: Connect to Your 3DCityDB Database

Click on the Database tab. This is where you tell the tool how to reach your PostgreSQL + 3DCityDB instance.

Fill in the connection details as follows:

Once all fields are filled, click Connect.

How do you know the connection worked?

If everything is correct, connection details and status messages will appear in the console panel on the right. If something goes wrong, error messages will be printed there, which makes troubleshooting much easier.

Connect Importer/Exporter to Your 3DCityDB Database

Step 3: Prepare the CityGML File for Import

Before importing anything, we always validate the CityGML file.

Why this matters: CityGML files are complex XML documents. Even small structural errors can cause:

Validation helps catch these issues early.

  1. Go to the Import tab.

2. Click on Browse and navigate to the tutorial dataset folder:

C:\RTG_Schulungskurs_2016\CityGML-Data\
Browse to CityGML-Data Folder in C: (which we saved in part 2 of this series)
Select the CityGML file

Select file —

Berlin_CityGML_Lod2.gml
Click Just validate
Check validation status in console

3. Click Just validate

The tool will now check the CityGML file against the official CityGML XML schema. When validation completes:

👉 Best practice:
Only import CityGML files that pass validation successfully. Importing invalid data often causes problems later during export, visualization, or querying.

Step 4: Import the CityGML into 3DCityDB

Once validation succeeds, you’re ready to import. You may notice several optional filters in the Import tab:

For this tutorial:

Now click Import.

A progress window will appear showing:

You can cancel the import at any time, but for this dataset, it usually completes within a few minutes.

Progress Window

Review the Import Summary

After the import finishes, a summary appears in the console showing:

This summary confirms that the CityGML data is now stored inside your 3DCityDB schema.

Console summary of imported datasets

At this point, your database is no longer empty — it contains a real 3D city model.

Verify the Database Contents

To double-check what’s inside the database:

  1. Go back to the Database tab
  2. Open the Database report sub-tab
  3. Click Generate database report

You’ll see a list of all 3DCityDB tables along with row counts — a great way to confirm that buildings, surfaces, and related objects were stored correctly.

Generate database report

Step 5: Calculate the City Bounding Box

Next, we’ll compute the spatial extent of the imported city model.

  1. Switch to the Bounding box tab
  2. Click Calculate

The tool will automatically compute:

These coordinates define the geographic footprint of the city model and will be used later for:

Calculate the City Bounding Box Coordinates

You can copy these values directly using the copy options provided.

Copy Coordinates

You can copy the coordinate values to the clipboard by clicking the button or by right-clicking on a coordinate value field and choosing the Copy bounding box option from the context menu.

What We Achieved in Part 4

At this point, you have:

This is a major milestone.

Your city is now stored semantically, spatially, and structurally inside a real 3D city database.

🌍 Beyond Berlin: Where to Find Open CityGML Datasets

In this tutorial series, we’re using a Berlin LoD2 CityGML dataset. However, Berlin is just one example.

If you’re curious to experiment with other cities, countries, or even global-scale models, there is an outstanding community-driven resource you should know about.

⭐ Awesome Semantic City Models (Open CityGML Datasets)

The “Awesome CityGML” GitHub repository curates one of the most comprehensive collections of open, semantic 3D city models available today. It brings together datasets published by universities, national mapping agencies, and city authorities around the world.

According to the latest update, the repository includes:

This means once you understand the workflow with Berlin, you can reuse the same steps to import:

🔗 Want to Explore More Cities?

If you’d like to try importing a different city or region, you can browse and download datasets from the Awesome CityGML repository on GitHub.

GitHub - OloOcki/awesome-citygml: The ultimate list of open data semantic 3D city models

The authors also request that if you use the repository in academic or professional work, you cite their paper and the Zenodo DOI, as it represents a significant community effort.

In the next steps, we’ll continue working with Berlin — but everything you learn here applies equally to any CityGML dataset you choose to explore.

⚙️ Importing CityGML Using the Command Line (Optional, Advanced)

So far in this tutorial, we’ve used the Importer/Exporter graphical interface, which is the easiest and most intuitive way to work with CityGML — especially when you’re just getting started.

However, it’s worth knowing that 3DCityDB also supports a full Command-Line Interface (CLI).

This means you can run imports, exports, validation, and cleanup operations directly from the terminal, without opening the GUI. The CLI becomes extremely useful when:

How the CLI works (high-level)

When you install the Importer/Exporter tool, it also installs a small executable called impexp.

Depending on your operating system:

This executable lives inside the bin folder of the Importer/Exporter installation and allows you to run commands such as:

All of these actions can be triggered using simple terminal commands.

The CLI is very powerful and comes with many options (logging, plugins, memory tuning, batch arguments). To keep this series beginner-friendly, we won’t dive deep into CLI syntax here.

If you’re interested in automation or server-side workflows, the official 3DCityDB documentation has a dedicated section on CLI usage — and we may cover a hands-on CLI example in a later advanced post.

4.9. Using the command-line interface (CLI) - 3dcitydb-docs 2024.0.1 documentation

Coming Next 👉

In the next part of the series, we’ll start exporting data:

This is where your city model becomes truly visual and interactive.

If you’re following along, feel free to:
💬 drop questions/feedback in the comments
⭐ follow the series for upcoming parts
🔔 Subscribe for email updates on 3DCityDB workflows

See you in Part 5 — where your city leaves the database and enters the real world 🌍🏙️

References