Converting to/from CityGML files

Table of contents

  1. Conversion CityGML -> CityJSON
  2. Conversion CityJSON -> CityGML

The open-source software citygml-tools allows us to automatically convert between CityGML-XML files v3.0/v2.0/v1.0 and CityJSON v2.0/v1.1/v1.0, and vice-versa.

Download its latest release (v2.2.0 at the time of writing this), and unzip its content. Notice that you need to have Java 11 or higher installed.

Open a console/terminal (also called “Command Prompt” in Windows)

The executable is at the root of the folder, type ./citygml-tools:

Conversion CityGML -> CityJSON

Download this CityGML file of The Hague (or any CityGML files; these can have textures too), and place it in a given folder (say /home/elvis/data/) To convert it to CityJSON:

./citygml-tools to-cityjson /home/elvis/data/DenHaag_01.xml

Voilà, you’re done, this creates a new CityJSON v2.0 file: /home/elvis/data/DenHaag_01.json

And now, if you drag that file into the viewer ninja, you can view it:

Conversion CityJSON -> CityGML

From the CityJSON file, a new GML file can be created with that command from-cityjson.