Skip to main content

Geospatial foundationsNew in v5.0

Coordinates with context.

Preserve CRS metadata across GeoParquet, GeoArrow, WKT, and more—so location data stays meaningful from file to map.

GeoParquetGeoArrowWKT

Coordinate meaning

Preserve first. Transform deliberately.

A loader can retain the coordinate definition without changing a single value. Reprojection is a separate, explicit operation with a named target.

Source data

12.4924, 41.8902
GeoParquetGeoArrowWKT
discover

CRS definition

EPSG:4326

identifier · axis order · epoch · provenance

choose
PreserveSame values + CRS
TransformNew values + target CRS

Coordinate meaning

Keep coordinates and their meaning together.

CRS metadata tells an application what coordinate values mean. loaders.gl preserves that definition during loading, while reprojection remains an explicit operation with a named target.

First step

Preserve the source definition and provenance

Second step

Transform only when the application requests it

Representations

EPSG identifiers, WKT, PROJ strings, and PROJJSON

Used by

GeoArrow, GeoParquet, FlatGeobuf, I3S, and 3D Tiles

Start here​

CRS support keeps the meaning of coordinates attached to loaded data and makes coordinate transformations explicit. Most applications can preserve the source metadata first and add reprojection only where it is needed.

Coordinate reference system (CRS) metadata tells an application how coordinates relate to the earth. Preserving that metadata is different from transforming coordinates. loaders.gl aims to make both explicit: loaders should first discover and retain the source CRS; reprojection only happens when a loader documents an opt-in transformation path.

Detailed guide

The CRS contract

The rest of this guide covers representations, shared descriptors, spatial APIs, axis order, heights, epochs, and failure behavior.

CRS representations​

  • A CRS identifier names a registered definition, for example EPSG:4326, OGC:CRS84, an OGC URN, or an OGC definition URL. Identifiers do not embed the definition and loaders.gl does not resolve them over the network.
  • WKT1, WKT2:2015, and WKT2:2019 serialize CRS definitions as text. WKT can also serialize coordinate operations and coordinate metadata. @math.gl/geospatial/crs parses WKT into a value-preserving syntax tree and encodes it again without inventing semantic equivalence.
  • A PROJ string is an ordered parameter serialization. It may describe a CRS or a pipeline. @math.gl/geospatial/crs preserves flags, repeated parameters, pipeline steps, and parameter order.
  • PROJJSON v0.7 is the canonical semantic object model exported by @math.gl/geospatial/crs. A WKT or PROJ syntax tree is not automatically convertible to PROJJSON.
  • A coordinate epoch identifies when coordinates in a dynamic CRS apply. GeoParquet stores it separately as epoch; it must not be confused with the CRS frame epoch.

Axis order belongs to the CRS definition. EPSG:4326 is latitude/longitude in authoritative axis order while OGC:CRS84 is longitude/latitude. Code should not assume those identifiers are interchangeable. loaders.gl geometry arrays and normalized bounds consistently use xy order (x/easting or longitude first); service adapters translate that canonical order to a protocol's wire order when required. A CRS may also be horizontal, vertical, or compound. Preserving only the horizontal component loses height datum information even when all coordinate values are retained.

Shared types and syntax codecs​

Install @math.gl/geospatial and import from @math.gl/geospatial/crs when a public application type needs to describe CRS values:

import type {
CRSDefinition,
CRSIdentifier,
PROJJSONCRS,
PROJStringDefinition,
ReadonlyCRSDefinition,
WKTCRSDefinition
} from '@math.gl/geospatial/crs';
import {encodePROJString, encodeWKTCRS, parsePROJString, parseWKTCRS} from '@math.gl/geospatial/crs';

CRSIdentifier is appropriate for service capabilities and request parameters. Embedded dataset metadata should use CRSDefinition, PROJJSONCRS, WKTCRSDefinition, or PROJStringDefinition, according to what the format actually stores.

The WKTCRSLoader and WKTCRSWriter remain loaders.gl adapters, but their v5 data shape is the WKTCRSAst exported by @math.gl/geospatial/crs. The old hybrid array/object result and the raw, sort, and debug options have been removed.

Experimental cross-source descriptor​

@math.gl/geospatial/crs exports the canonical, immutable SpatialReference descriptor for reporting CRS discovery consistently across vis.gl libraries. loaders.gl source and scan metadata reference that type directly rather than maintaining a loaders.gl-specific copy. It records a preferred definition and its representation, alternate source representations, provenance, coordinate epoch, stored component order, coordinate frame, and units. Its discriminated crs.state preserves four cases that applications must not collapse:

  • explicit: the format or caller supplied a usable definition;
  • default: the format specification establishes a usable definition;
  • unknown: the source explicitly says that its CRS is unknown;
  • absent: the source did not supply CRS metadata.

The initial loaders.gl adoption is exposed by I3S/3D Tiles spatial metadata and by FlatGeobuf vector-source and scan metadata. Existing format-specific fields remain available for compatibility and lossless preservation. The descriptor reports source discovery only: its presence never claims that coordinates, bounds, or heights were transformed. Import the shared type and constructor from their owning module:

import {createSpatialReference, type SpatialReference} from '@math.gl/geospatial/crs';
const metadata = await flatGeobufSource.getMetadata();
const spatialReference = metadata.layers[0].spatialReference;

if (spatialReference?.crs.state === 'explicit') {
console.log(spatialReference.crs.definition, spatialReference.crs.representation);
}

Reprojection contract​

Vector loader reprojection is opt-in and uses one public option shape:

type CRSReprojectionOptions = {
reproject?: boolean;
targetCrs?: ReadonlyCRSDefinition;
};

For Shapefile, FlatGeobuf, and GeoPackage this is supplied as gis: {reproject, targetCrs}. When reproject is enabled without a target, the compatibility target is WGS84. A target by itself does not transform coordinates. The output geometry and output CRS metadata are updated together; source metadata remains available for provenance. Missing source CRS metadata or an unsupported transformation throws CRSReprojectionError with a stable code; loaders never silently return source coordinates after a different target was requested.

Service vector requests distinguish requestCrs (the CRS of the input boundingBox) from crs (the CRS requested for returned feature coordinates). Service adapters preserve canonical xy application order and apply protocol-specific axis rules on the wire. Tile sources continue to use spatial.targetCrs, which controls requested output coordinates and is intentionally not aliased to gis.targetCrs.

Unknown or absent CRS metadata is preserved as unknown/absent. It is never treated as WGS84 for transformation. A loader may return native coordinates when reprojection was not requested, but a requested transform with unknown source CRS fails explicitly.

GeoArrow and GeoParquet need column-specific descriptors rather than one table-wide value. Raster, point-cloud, and service adoption will likewise retain format-specific details until the common shape can represent them without loss. Height placement modes, transformation status, warnings, and requested targets remain loaders.gl concerns; TilesetSpatialReference therefore extends the math.gl descriptor with those operational fields.

3D spatial API​

I3S and 3D Tiles share a normalized spatial descriptor in @loaders.gl/tiles. Normal loading does not require an application to populate source CRS, axis, epoch, or height-model fields. The format adapter discovers them and exposes the result on Tileset3D.spatialReference:

const tileset = new Tileset3D(source);
await tileset.tilesetInitializationPromise;

console.log(tileset.spatialReference);
// sourceCrs, coordinateFrame, heightReference, axisOrder,
// provenance, status, and warnings

provenance distinguishes explicit metadata from a format default, caller recovery override, legacy assumption, or unknown value. warnings reports qualifications such as an unresolved external metadata schema or an I3S ground-relative mode that needs an elevation provider. These fields are diagnostic output, not configuration.

The application-facing target contract is intentionally small:

type TilesetSpatialOptions = {
targetCrs?: ReadonlyCRSDefinition;
targetHeightReference?: 'native' | 'ellipsoidal' | 'orthometric';
outputCoordinates?: 'auto' | 'ecef' | 'local-enu' | 'target-crs';

// Expert recovery for missing or incorrect source metadata
sourceCrs?: ReadonlyCRSDefinition;
coordinateEpoch?: number;
geoidModel?: string | Geoid;

// Only needed when I3S metadata requests surface-relative placement
terrainElevationProvider?: TilesetElevationProvider;
sceneElevationProvider?: TilesetElevationProvider;
};

Source vertical units, height references, and I3S placement modes are discovered automatically. See Vertical Coordinate Systems and Elevation Placement for the operation order, provider contract, formulas, and failure behavior.

The v5 foundation normalizes these options and provides SpatialCoordinateTransformer for format-owned transformation paths. A descriptor with status transformable says that the requested operation can be constructed; only transformed can claim returned positions, bounds, normals, and origins have all moved into the target frame. During staged I3S/3D Tiles integration, applications should check the status instead of assuming a target rewrites every tile payload.

Registering non-bundled resources​

Common EPSG definitions supported by Proj4 require no setup. Custom definitions, datum grids, and geoid models are application resources registered once during startup:

import {registerGeoidModelFromPgm, registerSpatialCrs, registerSpatialDatumGrid} from '@loaders.gl/tiles-3d/spatial';

registerSpatialCrs('LOCAL:SURVEY_GRID', '+proj=tmerc +lat_0=... +lon_0=...');
registerSpatialDatumGrid('regional.gsb', datumGridArrayBuffer);
registerGeoidModelFromPgm('egm96-5', geoidPgmBytes, {cubic: true});

Registration is explicit. Loading a tileset never downloads an EPSG definition, NTv2 grid, or geoid model in the background. This keeps offline applications deterministic, avoids surprising network and licensing behavior, and lets each application choose its accuracy/resource tradeoff.

Division of responsibility​

ModuleResponsibilityDeliberate boundary
@math.gl/geospatial/crsTyped identifiers, WKT/PROJ syntax, and PROJJSON definitionsDoes not look up definitions or transform coordinates
@math.gl/geospatial/projectionHorizontal/projected/geocentric transformations and NTv2 grid registrationNot assumed to perform vertical datum or epoch operations
@math.gl/earthGeographicLib-compatible interpolation from application-supplied PGM dataIs not terrain and does not load a model automatically
@math.gl/geospatialEllipsoid, cartographic/ECEF, and local-frame mathematicsDoes not interpret format metadata
loaders.gl adaptersAxis normalization, profile semantics, bounds, origins, normals, elevation placement, and diagnosticsNever silently invent missing metadata

Vertical height conversion​

A geoid model returns undulation N, the signed separation between the ellipsoid and gravity-related height surface. loaders.gl follows the GeographicLib convention:

ellipsoidal height h = orthometric height H + geoid undulation N
orthometric height H = ellipsoidal height h - geoid undulation N

The geoid is sampled at longitude/latitude derived from the source horizontal CRS before the target horizontal projection. Conversion therefore needs a usable source CRS, known source height reference, finite Z value, and compatible registered model. Missing input is an error, not a reason to leave Z unchanged.

A geoid is not terrain. I3S onTheGround, relativeToGround, and relativeToScene modes need a terrain or scene elevation provider in addition to vertical datum conversion.

Axis order, precision, and bounds​

Format wire order is normalized before Proj4. Authoritative EPSG:4326 order is latitude/longitude, while I3S geometry and rendering arrays use longitude/latitude. SpatialCoordinateTransformer deliberately accepts conventional [x, y, z] arrays with Proj4 authority-axis enforcement disabled; the descriptor records the adapter's normalized order.

Positions remain Float64 through reconstruction and transformation. Rendering paths may downcast only after subtracting a nearby origin. Bounds are sampled or rebuilt in the target frame; an arbitrary projection must not be approximated by transforming two corners or attaching one affine matrix to a large tile.

SpatialCoordinateTransformer.transformPositions() batches finite horizontal-only XYZ transforms through a reusable math.gl projection buffer. It returns an owned Float64Array and leaves source arrays and typed-array views unchanged. Height conversion and geocentric transforms retain the per-position path.

Failure model​

Requested transformations reject when the source CRS is unknown, a preserved definition is not executable by Proj4, a custom definition/grid is unregistered, vertical conversion lacks a height model or geoid, an epoch operation is unsupported, local ENU has no derived origin, or relative placement lacks an elevation provider. The error names the missing resource or operation. A loader must not catch it and continue in source coordinates after a different target was requested.

Current support​

The table describes loaders.gl v5 behavior. “Partial” means some variants, output shapes, or metadata records are not yet normalized. “Implicit” means the format fixes or conventionally implies a coordinate system rather than carrying a general CRS definition. Preservation does not mean coordinate transformation.

Format or serviceDiscoveryPreservation / output metadataReprojection
GeoArrowField crs plus crs_type: PROJJSON, WKT2:2019, authority code, opaque-string SRID, or another opaque stringTyped field metadata; partial across converters that rebuild Arrow schemasNone
GeoParquet 1.1 / 2.0Per-column PROJJSON, null, omitted default, and coordinate epochOriginal geo JSON is retained; compatible GeoArrow field metadata is addedNone
Shapefile.prj WKT sidecar.prj is returned by legacy output; Arrow metadata is partialOpt-in through gis.reproject and targetCrs
FlatGeobufHeader authority code and WKT; common vector/scan spatialReference descriptorHeader metadata and alternate CRS representations are retained; Arrow CRS metadata is partialOpt-in through gis.reproject and targetCrs
GeoPackageSpatial reference system tables, preferring extension WKT2 over fallback WKT1Source and scan metadata retain the table CRS; Arrow geometry fields report the native or transformed output CRSOpt-in through gis.reproject and targetCrs
GeoJSONDeprecated GeoJSON crs member when present; otherwise WGS84 semanticsOriginal legacy value is retained; recognized CRS84/EPSG:4326 values map to GeoArrow/GeoParquet metadataNone in the GeoJSON loader
CSV WKT / WKBGeometry values can contain EWKT/EWKB SRIDs, but CSV has no dataset CRS conventionGeometry-level SRID support is partial; no common table CRS descriptorNone
GMLsrsName on geometry/envelope elementsParsed format data retains identifiers inconsistently across output shapesService/server dependent; no general client transform
GeoTIFF / COGGeoKeys and projected EPSG codesRaster source metadata exposes the detected native CRSNative CRS only; raster warping is not implemented
GeoZarrproj:wkt2, proj:code, grid_mapping, and CF WKT attributesRaster source metadata exposes the detected native CRSNative CRS only; mismatched viewport CRS is rejected
LAS / LAZWKT and GeoTIFF projection VLR/EVLR recordsRaw typed records are exposed in loader metadata; normalization is incompleteNone
COPCLAS CRS records plus COPC hierarchy metadataSame CRS limitations as LAS/LAZSource-specific normalization to WGS84 when a supported source definition is available; no general target-CRS contract
PotreeDataset projection metadata when suppliedSource metadata retains the projection stringExisting source-specific transform support only
WMSLayer CRS lists and CRS-tagged boundsNormalized capability and request identifiersServer-side CRS/SRS negotiation; no client raster warp
WFSCapability/request identifiers and GML srsNameIdentifier preservation is partialServer-side output CRS request where supported
WMTSTile-matrix-set supported CRSCapability metadataServer-selected tile matrix set; no client tile reprojection
ArcGIS servicesSpatial reference WKID/latestWKID fieldsService metadata and request fields are retainedServer-side outSR/image request behavior where implemented
I3SWKID/latestWKID, WKT, VCS WKIDs, heightModelInfo, ZFactor, elevationInfo, and extent CRSRaw fields plus normalized spatialMetadata; longitude/latitude wire order, vertical units, height references, and placement are explicitMesh and Point Cloud vertices, origins, normals, and bounds support requested geographic/projected output, geoid conversion, and all elevation placement modes with application providers
3D TilesCRS/epoch metadata semantics and region-established global framesRaw schema/entity metadata plus normalized spatialMetadata; local/unknown tilesets stay unknownShared transformer available; nonlinear content/bounds and nested-tileset integration is in progress
MVT / TileJSONImplicit tile coordinates; TileJSON bounds are longitude/latitudeTile transform and metadata retainedImplicit Web Mercator tiling; no arbitrary CRS
KMLImplicit WGS84 longitude/latitude/altitudeCoordinate values retainedNone
GPX / TCXImplicit WGS84 latitude/longitudeCoordinate values retainedNone

When gis.reproject is enabled, Shapefile, FlatGeobuf, and GeoPackage require usable source CRS metadata. A Shapefile therefore needs its .prj sidecar, while FlatGeobuf and GeoPackage need a source definition in their format metadata. Missing or invalid definitions reject the request; loaders.gl does not assume that unlabelled coordinates are WGS84.

GeoArrow and GeoParquet details​

GeoParquet distinguishes three states:

  • omitted crs: the GeoParquet default, OGC:CRS84
  • crs: null: an explicitly unknown CRS
  • crs: {…}: an explicit PROJJSON CRS

loaders.gl preserves that distinction in schema-level GeoParquet metadata. When mapping to GeoArrow field metadata, omitted CRS becomes the OGC:CRS84 authority identifier, explicit null emits no CRS field, and PROJJSON remains an object. A column epoch is preserved separately. GeoParquet has no crs_type member; unknown metadata members are nevertheless retained.

GeoArrow metadata is column-specific. Different geometry columns may have different CRSs, so a future normalized table descriptor must not collapse them into one table-wide value.

Known gaps​

  • Several Arrow output paths rebuild schemas without carrying all source CRS metadata.
  • LAS/LAZ/COPC expose projection records but do not yet assemble complete horizontal, vertical, dynamic, and compound CRS definitions.
  • GeoTIFF and GeoZarr return native-CRS raster data and do not warp or resample into a target CRS.
  • Vector loaders now use the shared gis.targetCrs name; the older _targetCrs spelling is not part of the v5 public contract.
  • Some point-cloud-specific transforms still treat an unsupported or unparsable source definition as an unavailable transform and continue with source coordinates instead of rejecting the request.
  • Some service parsers and format-specific structures still expose unclassified strings.
  • GeoParquet CRS metadata is preserved, but GeoParquet coordinates are not reprojected.
  • The experimental common descriptor covers I3S, 3D Tiles, and FlatGeobuf source discovery; column-specific table metadata, rasters, point clouds, and services do not yet all expose it.

Applications should not infer transformation from metadata presence or compare serialized definitions for semantic equality. They should also account for each loader's documented axis convention and failure behavior until the shared reprojection contract makes both explicit.

Roadmap​

  1. Extend the experimental discovery descriptor from tiles and FlatGeobuf to all source families, including representation, coordinate epoch, provenance, and explicit unknown/default state.
  2. Introduce one public reprojection contract; update output CRS and bounds after transformation, and reject unsupported transformations explicitly.
  3. Complete vector and table formats, including column-specific GeoArrow and GeoParquet CRS.
  4. Add complete LAS/COPC vertical, dynamic, and compound CRS handling.
  5. Add raster warping and resampling for GeoTIFF/COG and GeoZarr.
  6. Separate server-side CRS negotiation from client-side reprojection for service sources.
  7. Add datum-grid registration, transformation accuracy reporting, antimeridian handling, Z/M preservation, and deck.gl integration.

This roadmap deliberately does not make registry lookup or datum-grid downloads implicit. Those resources must be registered by the application so loading remains deterministic and browser-safe.