Converting to/from CityGML files

The open-source software citygml-tools allows us to automatically convert between CityGML and CityJSON, and vice-versa.

Download its latest release (v1.2.0 at the time of writing this), and unzip its content.

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

Then navigate to the folder /bin/, there is a program called citygml-tools. To see its capabilities, 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 /Users/hugo/temp/data/) To convert it to CityJSON:

./citygml-tools to-cityjson /Users/hugo/temp/data/DenHaag_01.xml

Voilà, this creates a new CityJSON file: /Users/hugo/temp/data/DenHaag_01.json

If you drag that file in the CityJSON web-viewer, you can view it:

Conversion CityJSON -> CityGML

From the CityJSON file, a new GML file can be created with that command: