This article details how to convert IFC data to GeoJSON. By converting IFC data to GeoJSON, you can preserve the properties inside the IFC data.

Why do it?

If you want to visualize an IFC dataset, you can convert it to OCG 3D Tiles, as explained in the Converting IFC data to OGC 3D Tiles tutorial. The OGC 3D Tiles conversion process converts only the IFC geometry, not the properties inside the IFC data. It stores only a unique identifier, called FeatureID, inside the OGC 3D Tiles data for each item. To prevent the loss of the properties defined inside the IFC data, you must convert them in another way.

To associate the OGC 3D Tiles data with the properties inside the IFC data, you must convert the so-called Feature data model. This model contains the properties defined in the IFC data. You can convert it to the GeoJSON format. This conversion maintains the properties stored inside the IFC dataset, together with the bounding box of each item. The FeatureID stored inside the OGC 3D Tiles data is also present as an identifier in the GeoJSON data.

LuciadFusion can natively serve IFC data as a WFS service. For that use case, you don’t need a manual conversion to GeoJSON. You can query the WFS service to retrieve the properties for a list of FeatureIDs. You can also query the WFS for items based on property values. This way, it’s possible to link the FeatureID contained in the OGC 3D Tiles with the original properties inside the IFC data.

Check the LuciadFusion documentation for more information on how to serve the IFC data as a WFS service.

To convert the IFC data to GeoJSON, you have two options: you can perform the conversion programmatically, or you can run the IFC data conversion script from the command line.

Converting IFC data to GeoJSON in your code

To convert IFC data to GeoJSON, you must first decode the features model. This model contains information about the structural elements in the IFC data, such as doors and walls. A bounding box is also available, but not the full geometry.

To convert IFC data to GeoJSON:

  1. Decode the IFC data into a features ILcdModel using the TLcdIFCModelDecoder.

    TLcdIFCModelDecoder decoder = new TLcdIFCModelDecoder();
    ILcdModel model = decoder.decodeFeatures(sourceName);
  2. Encode the features model to GeoJSON using a TLcdGeoJsonModelEncoder:

    TLcdGeoJsonModelEncoder encoder = new TLcdGeoJsonModelEncoder();
    encoder.export(model, destinationFile);

The resulting GeoJSON dataset is written to the given destinationFile file.

Converting IFC data to GeoJSON from the command line

To convert IFC data to GeoJSON, you use the same command line script as for converting the IFC data to OGC 3D Tiles. Make sure to pass the -g option on the command line to generate the GeoJSON output.