npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2025 – Pkg Stats / Ryan Hefner

ifc2geojson

v1.3.8

Published

Convert IFC (BIM) to GeoJSON (GIS) - Browser and Node.js compatible

Downloads

357

Readme

ifc2geojson - IFC to GeoJSON Converter

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.


Features

  • 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.

Installation

Install via npm:

npm install ifc2geojson

Usage

Importing

import {
  ifc2Geojson,
  ifc2GeojsonBlob,
  ifc2GeojsonWithFilter,
  ifc2GeojsonBlobWithFilter,
  getGeoPackagePropertiesFromGeoJSON,
  getElemsWithGeom
} from 'ifc2geojson';

Convert IFC → GeoJSON (object)

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);

Convert IFC → GeoJSON with Filtering

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);

Extract IFC element types that contain geometry

const elems = await getElemsWithGeom(ifcData);
console.log(elems);
// e.g., ["IfcWall", "IfcSlab", "IfcColumn"]

Extract GeoPackage Properties from GeoJSON

const properties = getGeoPackagePropertiesFromGeoJSON(geojson);
console.log(properties);
/*
[
  { name: "IfcEntity", dataType: "TEXT" },
  { name: "Name", dataType: "TEXT" },
  ...
]
*/

Browser Usage

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>

API Reference

ifc2Geojson(ifcData, crs?, msgCallback?)

Parses IFC and returns a GeoJSON FeatureCollection.

  • ifcData: Uint8Array
  • crs: CRS string (default "urn:ogc:def:crs:EPSG::3857")
  • msgCallback: progress callback

ifc2GeojsonWithFilter(ifcData, crs?, toFilter?, msgCallback?)

Like ifc2Geojson but allows filtering by IFC class names.


ifc2GeojsonBlob(ifcData, crs?, msgCallback?)

Like ifc2Geojson, but returns a Blob.


ifc2GeojsonBlobWithFilter(ifcData, crs?, toFilter?, msgCallback?)

Blob version of the filtered exporter.


getElemsWithGeom(ifcData)

Returns IFC element type names that have geometry.


getGeoPackagePropertiesFromGeoJSON(geojson)

Analyzes a GeoJSON FeatureCollection and outputs property names and GeoPackage-compatible data types.


Acknowledgements


License

This source code is licensed under the Mozilla Public License 2.0 (MPL-2.0).
See https://mozilla.org/MPL/2.0/.