This project provides tools to convert IFC (Industry Foundation Classes) models into 3D GeoJSON for GIS and web mapping applications. It includes a precision-aware GeoJSON exporter, IFC filtering, and utilities for generating GeoPackage schema from GeoJSON. See the live demo.
- Parses IFC data using web-ifc.
- Converts IFC geometries into 3D GeoJSON using three.js.
- Supports coordinate reference system (CRS) specification.
- Provides GeoPackage property type extraction for database schema generation.
- Reads and applies IfcMapConversion (IFC4) for direct georeferencing of models.
- Allows filtering of IFC elements (include/exclude by class) when exporting to GeoJSON.
- Improves coordinate precision with Float64Array geometry storage and georef offset strategy.
- Offers both object and Blob outputs for easy integration in Node.js or browser contexts.
Install via npm:
npm install ifc2geojsonimport {
ifc2Geojson,
ifc2GeojsonBlob,
ifc2GeojsonWithFilter,
ifc2GeojsonBlobWithFilter,
getGeoPackagePropertiesFromGeoJSON,
getElemsWithGeom
} from 'ifc2geojson';const crs = "urn:ogc:def:crs:EPSG::3857";
const ifcData: Uint8Array = /* load your IFC file */;
const geojson = await ifc2Geojson(ifcData, crs, (msg) => console.log(msg));
console.log(geojson);Filter IFC classes to include or exclude:
const toFilter = ["IfcWall", "IfcSlab"];
const geojson = await ifc2GeojsonWithFilter(
ifcData,
"urn:ogc:def:crs:EPSG::3857",
toFilter,
(msg) => console.log(msg)
);Or directly get a Blob:
const blob = await ifc2GeojsonBlobWithFilter(ifcData, "urn:ogc:def:crs:EPSG::3857", toFilter);const elems = await getElemsWithGeom(ifcData);
console.log(elems);
// e.g., ["IfcWall", "IfcSlab", "IfcColumn"]const properties = getGeoPackagePropertiesFromGeoJSON(geojson);
console.log(properties);
/*
[
{ name: "IfcEntity", dataType: "TEXT" },
{ name: "Name", dataType: "TEXT" },
...
]
*/To use this library directly in a browser environment, include the browser bundle (ifc2geojson.min.js) in your HTML and make sure to also host the required .wasm files (web-ifc.wasm, etc.) in the same directory or configure their paths properly. When all required files are properly imported in a browser environment, the API will be accessible via the global window.ifc2geojson object.
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
</head>
<body>
<input type="file" id="ifcInput" accept=".ifc" />
<script src="path/to/ifc2geojson.min.js"></script>
<script>
document.getElementById("ifcInput").addEventListener("change", async (e) => {
const file = e.target.files[0];
const arrayBuffer = await file.arrayBuffer();
const uint8 = new Uint8Array(arrayBuffer);
const { ifc2GeojsonBlob } = window.ifc2geojson;
const crs = "EPSG:4327";
const blob = await ifc2GeojsonBlob(uint8, crs, (msg) => {
console.log("Progress:", msg);
});
const url = URL.createObjectURL(blob);
const a = document.createElement("a");
a.href = url;
a.download = file.name.replace(/\.ifc$/i, ".geojson");
a.click();
});
</script>
</body>
</html>Parses IFC and returns a GeoJSON FeatureCollection.
ifcData:Uint8Arraycrs: CRS string (default"urn:ogc:def:crs:EPSG::3857")msgCallback: progress callback
Like ifc2Geojson but allows filtering by IFC class names.
Like ifc2Geojson, but returns a Blob.
Blob version of the filtered exporter.
Returns IFC element type names that have geometry.
Analyzes a GeoJSON FeatureCollection and outputs property names and GeoPackage-compatible data types.
web-ifc— IFC parsingthree.js— 3D geometry processingthree-geojson-exporter— inspiration for exportergeopackage-js— for GeoJSON → GeoPackage schema
This project has received funding from the European Union’s Horizon Europe programme under Grant Agreement No.101058559 (CHEK: Change toolkit for digital building permit).
This source code is licensed under the Mozilla Public License 2.0 (MPL-2.0).
See https://mozilla.org/MPL/2.0/.