Spatial metadata
Know what a Z value means before moving it.
Vertical coordinates combine stored units, height references, and placement rules. Keeping those questions separate prevents silent shifts in 3D scenes.
The three questions
Convert the value, identify the datum, then place the content.
A geoid is not terrain, and terrain is not a vertical CRS. loaders.gl keeps the metadata and execution layers distinct so each conversion can be inspected.
Stored unit
Feet, meters, or a format-specific scale
Height reference
Ellipsoidal, orthometric, or another datum
Placement
Absolute, terrain-relative, or surface-relative
Output
Renderer-relative coordinates after conversion
The vertical position of 3D content is governed by three independent questions:
| Question | Example metadata or option | What it changes |
|---|---|---|
| What unit is stored? | I3S heightUnit, ZFactor, elevationInfo.unit | Converts source Z values and offsets to meters |
| What surface is height measured from? | Ellipsoidal or orthometric height, vertical CRS, geoidModel | Converts between height datums |
| How is content placed? | I3S elevationInfo.mode, terrain or scene provider | Replaces or adds to source Z using a sampled surface |
These concepts are deliberately separate. A geoid converts between height references; it does not
describe terrain. A terrain provider supplies ground elevation; it does not identify whether that
elevation is ellipsoidal or orthometric unless its heightReference says so.
Detailed guide
Metadata and execution order
The sections below define the shared CRS layers, vertical metadata, placement formulas, and the order in which loaders.gl applies them.
Applications normally do not populate source-unit, vertical-CRS, height-model, or placement fields. I3S discovers them from layer metadata. Applications supply only a requested output, a geoid when datum conversion is needed, and a terrain or scene provider when the layer requests surface-relative placement.
Metadata and execution layers
The spatial pipeline builds on the shared math.gl CRS modules instead of defining a second CRS system inside loaders.gl:
| Layer | Responsibility |
|---|---|
@math.gl/geospatial/crs | Canonical immutable source CRS, vertical CRS, coordinate order, coordinate frame, epoch, and per-component units |
@math.gl/geospatial/projection | Executable geographic, projected, and geocentric coordinate transformations |
@math.gl/earth | Ellipsoidal/orthometric height conversion using an application-supplied geoid model |
@loaders.gl/tiles | Transformation status, target selection, format diagnostics, and shared spatial orchestration |
| I3S adapter | ZFactor, ArcGIS unit aliases, elevationInfo, surface providers, and geometry/bounds/origin placement |
TilesetSpatialReference extends the math.gl SpatialReference descriptor. Its crs, vertical,
coordinateOrder, and units fields are the canonical discovery result. Compatibility aliases
such as sourceCrs and operational values such as verticalUnitScale do not replace those fields.
All executable projection and geoid work flows through the shared tiles transformer; the I3S
adapter does not implement a separate projection or datum-conversion engine.
Order of operations
loaders.gl applies vertical operations in a fixed order:
- Discover the horizontal CRS, vertical CRS, source height reference, vertical unit, and I3S placement mode.
- Convert stored source Z to meters. An explicit legacy I3S
ZFactortakes precedence overheightUnit, avoiding a duplicate conversion on layers that publish both. - Convert
elevationInfo.offsetfrom its declared unit to meters. - Sample the terrain or scene surface when the placement mode requires it.
- Convert provider heights into the layer's source height reference, if the provider declares a different reference.
- Apply the placement formula in the source height reference.
- Convert to the requested target height reference with the configured geoid.
- Transform horizontal coordinates, rebuild bounds, select a stable origin, and only then
downcast renderer-relative offsets to
Float32.
Node-bound centers follow the source vertical unit, while I3S sphere radii and OBB half-sizes are metric. The implementation keeps those paths separate so unit conversion does not scale a tile's physical extent.
I3S placement formulas
After normalizing all values to meters in the layer's source height reference, loaders.gl uses the following formulas:
absoluteHeight = sourceZ + offset
onTheGround = terrain
relativeToGround = terrain + sourceZ + offset
relativeToScene = scene + sourceZ + offset
onTheGround intentionally ignores source Z and offset. relativeToScene uses a separately
configured scene-surface provider; loaders.gl does not substitute terrain because the visible
scene can include buildings or other 3D content above the ground.
An elevationInfo unit applies to its offset. Constant or Arcade feature expressions are
preserved in I3S metadata, but per-feature expression evaluation belongs to renderer and popup
support and is not part of the spatial placement pipeline.
Supplying terrain and scene elevations
Surface providers receive WGS84 longitude/latitude pairs in degrees, regardless of the layer or requested target CRS. They return one finite height per location in the same order. Calls are batched per geometry or bound operation and may be synchronous or asynchronous.
import type {TilesetElevationProvider} from '@loaders.gl/tiles-3d';
import {I3SSource, Tileset3D} from '@loaders.gl/tiles-3d';
import {I3SLoader} from '@loaders.gl/tiles-3d/i3s';
const terrainElevationProvider: TilesetElevationProvider = {
heightReference: 'orthometric',
unit: 'meter',
async sampleElevations(longitudeLatitudes) {
return elevationService.sample(longitudeLatitudes);
},
async getElevationRange(bounds) {
return elevationService.getConservativeRange(bounds);
}
};
const source = new I3SSource({url: layerUrl, loader: I3SLoader});
const tileset = new Tileset3D(source, {
spatial: {
targetCrs: 'EPSG:4326',
targetHeightReference: 'ellipsoidal',
terrainElevationProvider,
geoidModel: 'egm96-5'
}
});
await tileset.tilesetInitializationPromise;
Point Cloud layers use the same contract directly on I3SPointCloudSource:
const source = new I3SPointCloudSource(layerUrl, {
spatial: {
targetCrs: 'EPSG:3857',
terrainElevationProvider
}
});
await source.initialize();
Use terrainElevationProvider for onTheGround and relativeToGround. Use
sceneElevationProvider for relativeToScene. If unit is omitted, meters are assumed. If
heightReference is omitted, the layer's source height reference is assumed. Declaring the
provider reference is recommended when its service contract is known.
getElevationRange() must return conservative minimum and maximum heights over the complete
WGS84 footprint, including interior extrema. Bounds may cross the antimeridian, indicated by
west > east. Point samples are used for actual geometry placement; the range operation is used
for traversal bounds so an interior peak or depression cannot be culled. Invalid or
non-conservative ranges violate the provider contract.
loaders.gl never fetches terrain implicitly. This keeps loading deterministic and avoids coupling a format loader to one terrain vendor, credential scheme, resolution, or licensing model.
Units
Common metric, international, US survey, and historical ArcGIS linear unit names are normalized
to meters. This includes meter, millimeter, centimeter, decimeter, kilometer, foot, yard, mile,
US survey variants, and the Clarke, Sears, Benoit, Indian, and Gold Coast units used by legacy CRS
definitions. Common spellings and abbreviations such as metre, m, ft, and
us-survey-foot are accepted.
When the source association is unambiguous, the original per-component units are reported on the
canonical spatialReference.units array in stored coordinate order. The I3S adapter additionally
derives a meters-per-source-Z scale for placement math. That derived scale is operational metadata,
not a competing CRS definition.
An unknown unit is an unresolved spatial operation and rejects initialization. It is never treated as meters silently. This applies to source Z, elevation offsets, and provider results.
Geoids and height references
Ellipsoidal height h, orthometric height H, and geoid undulation N follow the GeographicLib
convention:
h = H + N
H = h - N
The same application-supplied @math.gl/earth model can normalize a provider into the layer's
height reference and then convert the placed result into the requested output height reference.
The geoid is sampled at the geographic location before target projection.
Register reusable PGM resources during application startup, or pass an already parsed Geoid:
registerGeoidModelFromPgm('egm96-5', geoidPgmBytes, {cubic: true});
const spatial = {
targetHeightReference: 'orthometric' as const,
geoidModel: 'egm96-5'
};
No model is downloaded automatically. A requested ellipsoidal/orthometric conversion without a known source height reference or compatible geoid fails explicitly.
Bounds, traversal, and initialization
Surface placement is asynchronous, so I3S sources prepare the root bound before runtime tile
initialization. Child bounds and payload positions use the same provider and operation order.
Mesh traversal retains WGS84 ECEF bounds, Point Cloud traversal retains geographic bounds, and
both expose a parallel spatialBoundingVolume in the requested target frame.
A curved or varying surface is represented with the provider's conservative elevation range over the complete bound footprint rather than corner samples or a single Z translation. The result is conservative for culling and remains dateline-aware.
Failure behavior
Initialization or loading rejects when:
- a surface-relative mode has no matching terrain or scene provider;
- a surface provider cannot report a conservative range for traversal bounds;
- a provider returns the wrong number of values or a non-finite value;
- a source, offset, or provider unit is unsupported;
- provider and layer height references differ but cannot be converted;
- a requested height-datum conversion has no compatible geoid; or
- source CRS or height-reference metadata needed by the operation is unknown.
The loader does not catch these failures and continue with unplaced coordinates. Applications can
inspect spatialReference.status and spatialReference.warnings before loading child content.
3D Tiles
3D Tiles and I3S share target CRS, target height-reference, geoid registration, precision, and
bound-rebuilding infrastructure. Standard 3D Tiles global coordinates are ECEF meters and do not
define I3S-style elevationInfo placement modes, so terrain and scene providers are not applied to
3D Tiles implicitly. Format-specific metadata semantics may identify a source CRS or coordinate
epoch; local or unknown tilesets remain unresolved until the application supplies an expert source
override.
See Coordinate Reference Systems for the cross-format model and Coordinate reference systems in I3S for I3S-specific discovery and source examples.