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

Why do it?

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

To associate the OGC 3D Tiles data with the metadata inside the Revit data, you must convert the so-called Feature data model. This model contains the metadata defined in the Revit data. You can convert it to the GeoJSON format. This conversion maintains the metadata stored inside the Revit 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 Revit 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 metadata inside the Revit data.

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

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

Converting Revit data to GeoJSON in your code

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

To convert Revit data to GeoJSON:

  1. Decode the Revit data into a features ILcdModel using the TLcdRevitModelDecoder.

    TLcdRevitModelDecoder decoder = new TLcdRevitModelDecoder();
    ILcdModel model = decoder.decodeSource(new TLcdBIMDataSource(sourceName, TLcdBIMDataSource.Type.FEATURES));
  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 Revit data to GeoJSON from the command line

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