<aside> 🆕 This feature was introduced in xeokit-sdk v2.0.

</aside>

<aside> ℹ️ See also: Viewing a CityJSON model with CityJSONLoaderPlugin

</aside>



Introduction

In this mini-tutorial, we'll use xeokit's [convert2xkt](<https://xeokit.github.io/xeokit-convert/docs/>) CLI tool to convert a CityJSON model into xeokit's native XKT geometry format, which we'll then view in the browser using a xeokit Viewer.

CityJSON is a JSON-based encoding for a subset of the OGC CityGML data model (version 2.0.0), and is now published as an OGC community standard.

The XKT format compresses models into a compact payload from which xeokit can load large numbers of objects over the Web in seconds, at full geometric precision.

For our CityJSON file, we'll use a LoD-3 model of a railway line, which is one of the sample datasets provided at here. When that's converted and loaded, it will look like the example below.

<aside> ▶️ Run this example

</aside>

E5reSOwXwAQw_CN.jpeg

1. Install convert2xkt

Using git and npm, clone and install our xeokit-convert repository, which contains the convert2xkt tool that we'll use to convert our CityJSON into XKT.

Be sure to use the latest versions of both xeokit-convert and xeokit-sdk.

git clone <https://github.com/xeokit/xeokit-convert.git>
cd xeokit-convert
npm install

2. Convert CityJSON to XKT

Now convert the CityJSON into an XKT file:

node convert2xkt.js -s LoD3_Railway.json -o LoD3_Railway.json.xkt -l

[convert2xkt] Reading input file: LoD3_Railway.json
[convert2xkt] Input file size: 4521.41 kB
[convert2xkt] Converting...
[convert2xkt] Converting CityJSON 1.0
[convert2xkt] Rotating model about X-axis
[convert2xkt] Converted objects: 120
[convert2xkt] Converted geometries: 36984
[convert2xkt] Converted triangles: 113537
[convert2xkt] Converted vertices: 170281
[convert2xkt] Converted to: XKT v9
[convert2xkt] XKT size: 878.98 kB
[convert2xkt] Compression ratio: 5.14
[convert2xkt] Conversion time: 2.99 s
[convert2xkt] Writing XKT file: LoD3_Railway.json.xkt