Skip to main content

@math.gl/geospatial

From-v3.0

@math.gl/geospatial provides ellipsoid geometry, geographic/Cartesian conversions, local tangent frames, globe queries, and tile-grid geometry. Use it for WGS84 positions and 3D Tiles bounds without a renderer dependency.

Geographic arrays use [longitude, latitude, height], with angles in degrees and ellipsoidal height in metres by default. Cartesian arrays use Earth-centered coordinates in metres. Geoid heights and general CRS conversion are handled by geoid and projection.

The geospatial group includes @math.gl/geospatial, /globe, /tiles, /crs, /projection, /maps, /web-mercator, /expressions, and /terrain. @math.gl/geospatial/web-mercator remains available for existing imports. DGGS remains a separate package.

Arrow, GeoArrow, and WKB/WKT representations live in @math.gl/core/arrow.

New to these concepts? Start with Geospatial terminology for geodesics, rhumb lines, chords, ellipsoids, reference systems, and projection properties.

Usage​

Determine the Cartesian representation of a Cartographic position on a WGS84 ellipsoid.

import {Ellipsoid} from '@math.gl/geospatial/ellipsoid';
const cartographicPosition = [21, 78, 5000]; // [longitude, latitude, height]
const cartesianPosition = Ellipsoid.WGS84.cartographicToCartesian(cartographicPosition);

Determine the Cartographic representation of a Cartesian position on a WGS84 ellipsoid.

import {Ellipsoid} from '@math.gl/geospatial/ellipsoid';
const cartesianPosition = [17832.12, 83234.52, 952313.73];
const cartographicPosition = Ellipsoid.WGS84.cartesianToCartographic(cartesianPosition);

Get the transform from a local east-north-up frame at a point on the WGS84 ellipsoid to Earth's fixed frame.

import {Ellipsoid} from '@math.gl/geospatial/ellipsoid';
import {eastNorthUpToFixedFrame} from '@math.gl/geospatial/coordinates';
const cartesianOrigin = Ellipsoid.WGS84.cartographicToCartesian([21, 78, 0]);
const transformMatrix = eastNorthUpToFixedFrame(Ellipsoid.WGS84, cartesianOrigin);

Features​

FeatureSupportNotes
Ellipsoid coordinates and surface geometryβœ…Ellipsoid, metric/auxiliary-latitude helpers, and qualified surface inversion.
Local frames, poses and packed transformsβœ…LocalReferenceFrame with explicit ENU/NED conventions and documented ownership.
Series and elliptic-integral geodesicsβœ…Series and Exact solvers have distinct oblate/prolate support profiles.
Geodesic area, rhumbs and intersectionsβœ…Polygon accumulation, rhumb geometry, and bounded intersection searches.
Surface paths, seams and clippingβœ…Geodesic/rhumb paths, geographic seams and global/latitude cut APIs preserve declared edge semantics.
Triaxial coordinates, direct paths and samplingβœ…TriaxialEllipsoid supplies surface conversions, initial-value geodesics and surface sampling within documented domains.
Globe visibility and tile-matrix geometryβœ…Globe queries and tile matrices remain independent of tile loading/rendering.
UTM/UPS, MGRS and angle utilitiesβœ…Coordinate utilities implement explicit WGS84 grid, envelope and formatting conventions.
Batched columnar GIS operationsβœ…The optional Turf-compatible entry operates on GeoArrow columns with nullable row-aligned results; its supported operation set is explicit.
Full global triaxial inverse geodesics❌Direct triaxial trajectories do not provide a global inverse/closest-route or route-uniqueness solver.
Precision encoding with a renderer contract◐Local frames are implemented; the C7 roadmap retains shared high/low encoding and consumer qualification work.
Qualified inertial/terrestrial state-vector frames❌Versioned Earth-orientation providers and full position/velocity frame transformations remain C9 work.

Installation​

npm install @math.gl/geospatial

WGS84: The 1984 World Geodetic System Ellipsoid

WGS84: The 1984 World Geodetic System Ellipsoid.
Attribution: From wikipedia, Creative Commons 4.0.

Import paths​

ImportAPIs
@math.gl/geospatial/ellipsoidReference ellipsoids, metrics, and tangent planes.
@math.gl/geospatial/geodesicsGeodesics, rhumb lines, and distance and area calculations.
@math.gl/geospatial/coordinatesCoordinate formats, grid systems, and local reference frames.
@math.gl/geospatial/globeGlobe visibility, bounding regions, and mesh subdivision.
@math.gl/geospatial/geographic-cutsGeographic seams, clipping, and chart boundaries.
@math.gl/geospatial/tilesGeographic tiles and tile matrices.
@math.gl/geospatial/crsCoordinate reference system definitions and resolution.
@math.gl/geospatial/projectionCoordinate transformations and projection engine APIs.
@math.gl/geospatial/mapsMap projections, surfaces, and transitions.
@math.gl/geospatial/terrainTerrain sampling, mesh generation, and surface analysis.
@math.gl/geospatial/web-mercatorSpherical Web Mercator viewport and coordinate utilities.
@math.gl/geospatial/st-functionsPostGIS-style functions for Arrow SQL
@math.gl/geospatial/st-hull-functionsConvex and concave point-cloud footprints for Arrow SQL
@math.gl/geospatial/st-overlay-functionsPoint and line buffers plus polygon overlays with native GeoArrow output
@math.gl/geospatial/st-viewport-functionsGeometry clipping and subdivision for Arrow SQL
@math.gl/geospatial/turf-functionsTurf function declarations and the Arrow SQL adapter
@math.gl/geospatial/tasksMap preparation and coordinate projection tasks

Classes​

ClassDescription
EllipsoidImplements ellipsoid math and cartographic/Cartesian conversions.
Ellipsoid.WGS84An Ellipsoid instance initialized with Earth radii per WGS84.
LocalReferenceFrameReusable local frames, geographic poses, and velocity-aligned orientations.
EllipsoidTangentPlaneProjects WGS84 Cartesian positions into a local east-north plane.
LngLatRectangleRepresents a longitude-latitude rectangle, including antimeridian crossing.

Geographic tile queries​

Loading Geographic tile explorer…

Geographic tile helpers address degree coordinates and cover geographic regions with compact tile ranges, including antimeridian crossings. Expand the infobox to explore query regions and levels.

Functions​

FunctionDescription
makeOBBFromRegionCreates a conservative oriented bounding box for a longitude–latitude–height region, including antimeridian and polar regions.

Framework Independence​

Input coordinates can be numeric arrays; callers do not need to construct core vectors.

  • Coordinate inputs and outputs use three-component numeric arrays. Check each method's result parameter before supplying reusable storage.

History​

This library was initially created as part of a bigger collaboration between the vis.gl and Cesium teams to provide framework-independent, portable support for the 3D Tiles specification, however it has been designed to provide generic support for WGS84 and ellipsoidal math.

Attribution​

Selected classes and three-radius ellipsoid kernels derive from Cesium under Apache-2.0. Shared spheroid conversion kernels also retain proj4js MIT provenance. Source headers and distributed notices identify the applicable credits and terms.

See Attributions for the project-wide source inventory and acknowledgments.

Globe queries​

EllipsoidOccluder and globe horizon bounds provide true ray intersections, elevated-point occlusion, exact limb ellipses and wrapped conservative imagery coverage without a viewport or rendering dependency.

Globe mesh subdivision​

subdivideGlobeMesh refines triangulated longitude/latitude meshes onto a sphere or oblate ellipsoid, preserving shared edges and attribute provenance. Import it and SubdivideGlobeMeshOptions from @math.gl/geospatial.

Tile matrices​

Tile matrix types and utilities describe supplied rectangular grids in any coordinate system. Import from @math.gl/geospatial for a lightweight entry point with no runtime dependencies. Helpers provide bounds, coordinate lookup, compact extent-to-tile ranges, coverage checks and resolution-based level selection.

Use the geographic tile helpers above for the built-in equal-angle longitude/latitude quadtree and antimeridian-aware queries. Explicit matrix queries use half-open edges and never wrap.

Local frames and poses​

LocalReferenceFrame separates point and vector transformations, composes geographic heading/pitch/roll poses, and builds velocity-aligned orientations. Import it from @math.gl/geospatial. Local distances use the ellipsoid axis units; pose angles use radians.

Geodesic path sampling​

GeodesicPath reuses a shortest geodesic line for fraction/distance sampling. subdivideGeodesicPolyline adaptively maps those paths through a supplied transform with original-edge provenance and optional surface-distance limits. Source angles are degrees, output tolerance uses target units, and longitude unrolling does not split projection seams. Import the sampler from /ellipsoid and subdivision from /globe.

Local-frame qualification and G7 benchmark baselines document the supported numerical profile and independent/native evidence.

Wider-domain and triaxial geodesics​

Optional coordinate utilities provide angle text and WGS84 UTM/UPS/MGRS cells. Packed line sampling adds reusable geodesic/rhumb output storage. Triaxial geometry also supports area-uniform surface points.

Web Mercator​

Import map viewport and Mercator coordinate utilities from @math.gl/geospatial/web-mercator.