@spatialdata/core
v0.2.5
Published
Core library for interfacing with SpatialData stores
Readme
@spatialdata/core
Core library for interfacing with SpatialData stores in TypeScript/JavaScript.
Node REPL
readZarr is async, and @spatialdata/core is published as ESM. In a Node REPL, the simplest pattern is to use await import(...).
If you are working inside this monorepo, note that test-fixtures/ is gitignored. Generate the sample fixture first, then build so the package entrypoint exists:
pnpm test:fixtures:generate:0.7.2
pnpm build
nodeThen in the REPL:
const { readZarr } = await import('./packages/core/dist/index.js');
const { FileSystemStore } = await import('@zarrita/storage');Open a local store from disk
Pass an explicit zarrita store instance. Plain filesystem path strings are not supported by readZarr.
const store = new FileSystemStore('./test-fixtures/v0.7.2/blobs.zarr');
const sdata = await readZarr(store);
sdata.toString();
Object.keys(sdata.images ?? {});
sdata.coordinateSystems;Open a remote store over HTTP
Pass the store URL directly:
const { readZarr } = await import('./packages/core/dist/index.js');
const sdata = await readZarr('http://localhost:38473/v0.7.2/blobs.zarr');
sdata.url;
Object.keys(sdata.images ?? {});If you want to try that example against this repo's generated fixtures:
pnpm test:fixtures:generate:0.7.2
pnpm test:serverUsing an installed package
If @spatialdata/core is installed in another project, use the package name instead of the local dist path:
const { readZarr } = await import('@spatialdata/core');
const { FileSystemStore } = await import('@zarrita/storage');
const sdata = await readZarr(new FileSystemStore('/absolute/path/to/store.zarr'));Common gotchas
- The REPL is not an ESM module file, so prefer
await import(...)rather thanimport { readZarr } from .... - Local disk access should use
new FileSystemStore(...), not a bare path string. - URL-backed loads set
sdata.url; store-backed loads keepsdata.url === undefinedand retain the original object onsdata.source. - If the REPL says it cannot find
./packages/core/dist/index.js, runpnpm buildfirst.
Development
The documentation package has a dependency on packages/core and can be used for experimenting with functionality inline with the documentation itself.
# Install dependencies
pnpm install
# develop docs & packages
pnpm dev
# Run tests
pnpm test
# Build
pnpm buildLicense
MIT
