Space and time

E2 cells combine a spatial index, a time bucket, and an optional feature ID into a stable identifier.

Documentation navigation

Encode and decode

cells.ts
import { E2 } from "@embed-earth/sdk-test";

const e2 = new E2();
const id = e2.encode({
  lat: 40.7,
  lng: -74,
  time: "2026-08-18T00:00:00Z",
  spatialResolution: 9,
  temporalResolution: "1d",
  feature: "restaurant",
});

const parsed = e2.decode(id);
console.log(parsed.temporal.resolution, parsed.featureId);
Use a feature key or numeric ID with the SDK's friendly feature option. The lower-level core API accepts featureId.

Cell shape

SegmentMeaning
e2E2 namespace.
1Cell format version.
spatialSpatial index at resolution 0 through 15.
temporal resolutionOne of 1s, 10s, 1m, 5m, 15m, 1h, 6h, 1d, or 7d.
temporal bucketInteger bucket relative to the E2 epoch.
feature IDOptional positive safe integer.

Base cells have five segments; feature cells add a sixth feature ID segment. Parsing rejects invalid spatial indexes, unknown temporal resolutions, extra suffixes, and non-integer buckets.

Traverse cells

traverse.ts
const base = e2.baseCell(id);
const neighbors = e2.spatialNeighbors(base, 1);
const parent = e2.spatialParent(base);
const next = e2.temporalNext(base);
const previous = e2.temporalPrevious(base);
const children = e2.temporalChildren(base);
const range = e2.resolveWindow("30d");

Available operations include spatial parents, children, neighbors, feature attachment, temporal parents, children, previous, next, cell-to-time ranges, and coverage.