Skip to main content

Scientific module · API reference

Bring a NumPy array into a typed JavaScript pipeline.

NPYLoader handles the compact NumPy array format and returns the typed data together with the header metadata needed to interpret its dimensions and storage order.

What comes back

Values plus the metadata that makes them useful.

The loader returns a typed array for the values and a small header describing dtype, Fortran order, and dimensions. The array is ready for application or texture conversion code.

Data

TypedArray selected from the NPY descriptor

Dtype

Element kind, width, and byte order

Shape

Dimensions of the multidimensional array

Order

C-order or Fortran-order storage metadata

Detailed guide

NPYLoader details

The reference below covers the supported file shape, usage, returned header fields, and current option boundaries.

NPYLoader

From-v3.0

The NPYLoader parses an array from the NPY format, a lightweight encoding of multidimensional arrays used by the Python NumPy library.

NPYLoader
File Extension.npy
File TypeBinary
File FormatArray
Data FormatArray
Supported APIsload, parse, parseSync
Decoder TypeSynchronous
Worker Thread✅ Yes
Streaming Support❌ No

Usage​

import {NPYLoader} from '@loaders.gl/scientific/npy';
import {load} from '@loaders.gl/core';

const {data, header} = await load(url, NPYLoader);

data is a TypedArray containing the array's data.

header is an object with three keys:

  • descr: a string describing the data type. E.g. |u1 refers to uint8 and <u2 refers to little-endian uint16. Full details are available in the NumPy documentation.
  • fortran_order: a boolean that is true if the array is stored in Fortran order instead of C order.
  • shape: an array of integers that describes the shape of the array. The length of the array corresponds to the number of dimensions of the array.

Options​

Currently no options are supported for this loader.

OptionTypeDefaultDescription

For synchronous access, use NPYLoaderWithParser from @loaders.gl/scientific/npy with parseSync. The package root exports metadata and preloads the parser for async APIs.