@math.gl/geospatial
@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β
| Feature | Support | Notes |
|---|---|---|
| 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
Attribution: From wikipedia, Creative Commons 4.0.
Import pathsβ
| Import | APIs |
|---|---|
@math.gl/geospatial/ellipsoid | Reference ellipsoids, metrics, and tangent planes. |
@math.gl/geospatial/geodesics | Geodesics, rhumb lines, and distance and area calculations. |
@math.gl/geospatial/coordinates | Coordinate formats, grid systems, and local reference frames. |
@math.gl/geospatial/globe | Globe visibility, bounding regions, and mesh subdivision. |
@math.gl/geospatial/geographic-cuts | Geographic seams, clipping, and chart boundaries. |
@math.gl/geospatial/tiles | Geographic tiles and tile matrices. |
@math.gl/geospatial/crs | Coordinate reference system definitions and resolution. |
@math.gl/geospatial/projection | Coordinate transformations and projection engine APIs. |
@math.gl/geospatial/maps | Map projections, surfaces, and transitions. |
@math.gl/geospatial/terrain | Terrain sampling, mesh generation, and surface analysis. |
@math.gl/geospatial/web-mercator | Spherical Web Mercator viewport and coordinate utilities. |
@math.gl/geospatial/st-functions | PostGIS-style functions for Arrow SQL |
@math.gl/geospatial/st-hull-functions | Convex and concave point-cloud footprints for Arrow SQL |
@math.gl/geospatial/st-overlay-functions | Point and line buffers plus polygon overlays with native GeoArrow output |
@math.gl/geospatial/st-viewport-functions | Geometry clipping and subdivision for Arrow SQL |
@math.gl/geospatial/turf-functions | Turf function declarations and the Arrow SQL adapter |
@math.gl/geospatial/tasks | Map preparation and coordinate projection tasks |
Classesβ
| Class | Description |
|---|---|
Ellipsoid | Implements ellipsoid math and cartographic/Cartesian conversions. |
Ellipsoid.WGS84 | An Ellipsoid instance initialized with Earth radii per WGS84. |
LocalReferenceFrame | Reusable local frames, geographic poses, and velocity-aligned orientations. |
EllipsoidTangentPlane | Projects WGS84 Cartesian positions into a local east-north plane. |
LngLatRectangle | Represents 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β
| Function | Description |
|---|---|
makeOBBFromRegion | Creates 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β
- EllipsoidGeodesicExact: optional elliptic direct/inverse revolution geodesics and reusable distance/arc lines.
- TriaxialEllipsoid: three surface coordinate systems, direction conversions and reusable Cartesian geodesic trajectories.
- G8/G9 qualification and support limits.
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.