COPC

raw JSON →
0.0.8 verified Sat Apr 25 auth: no javascript

A TypeScript library for reading and parsing Cloud Optimized Point Cloud (COPC) data, version 0.0.8. It provides utilities to initialize a COPC object from a file or getter, traverse the hierarchy pages, and read point data views with typed dimension access. The library is pre-1.0 and actively maintained on GitHub with CI. It differentiates from other point cloud libraries by focusing specifically on the COPC format, offering a simple async API, and shipping TypeScript types.

error Error: Could not find module 'copc'
cause Missing npm install or ESM import syntax not transpiled.
fix
npm install copc and ensure your project is set up for ESM (e.g., "type": "module" in package.json).
error TypeError: Copc.create is not a constructor
cause Using CommonJS require instead of ESM import.
fix
Replace 'const Copc = require("copc")' with 'import { Copc } from "copc"'.
error Cannot find name 'CopcHeader'
cause Trying to use CopcHeader as a value, but it is only a type.
fix
Import as a type: 'import type { CopcHeader } from "copc"'.
breaking Version 0.x may have breaking changes between minor versions. The API is not stable.
fix Pin to a specific version and test after upgrades.
gotcha The library requires a file path or getter, not a URL. For remote files, you must implement a getter that fetches byte ranges.
fix Provide a custom async getter function that returns ArrayBuffer for given byte offset and length.
deprecated As of v0.0.8, no deprecations are known. However, pre-1.0 releases may deprecate features without notice.
fix Watch the GitHub repository for changelog.
npm install copc
yarn add copc
pnpm add copc

Shows how to initialize a Copc object, load the root hierarchy page, and read point data using dimension getters.

import { Copc } from 'copc';

async function main() {
  const filename = 'path/to/file.copc.laz';
  const copc = await Copc.create(filename);
  console.log('Header:', copc.header);
  console.log('Info:', copc.info);
  
  const { nodes } = await Copc.loadHierarchyPage(filename, copc.info.rootHierarchyPage);
  const root = nodes['0-0-0-0'];
  if (root) {
    const view = await Copc.loadPointDataView(filename, copc, root);
    console.log('Dimensions:', view.dimensions);
    const getX = view.getter('X');
    const getY = view.getter('Y');
    const getZ = view.getter('Z');
    const x = getX(0);
    const y = getY(0);
    const z = getZ(0);
    console.log(`Point 0: (${x}, ${y}, ${z})`);
  }
}

main().catch(console.error);