JuliaCon 2025

Geometry on the sphere with GeometryOps.jl
2025-07-23 , Main Room 3

Modern global geospatial workflows are ill-served by our current conception of planar geometry. In GeometryOps.jl, we have added support for operations natively on the sphere (the space ), akin to Google's s2 library. This allows us to treat lines as great-circle arcs without subsampling, and calculations like area and intersection are natively non-approximate. This enables fast and substantially more accurate global operations, especially on areas of particular interest like the poles.


The Earth is approximately ellipsoidal, but we can approximate it as a perfect sphere with only ~0.5% maximum error - making it suitable for most uses.

Geometric operations on the sphere (like polygon intersection, area, or arclength) have an inherent accuracy that cannot be matched by projecting to any planar space. This is because spherical calculations are globally accurate. Google's s2 library and Charles Karney's GeographicLib (now part of the Proj library) were pioneers in this space. We take inspiration from these libraries, while continuing to optimize further.

This work was inspired and required by three main use cases:

  1. Planar representations struggle with geometry that encircles the poles or crosses the antimeridian (-180 degree line). Systems of geometry that span the globe, like global grid systems, or geometries that encircle the poles, as may happen in ocean simulations, are difficult to represent on a plane. Spherical geometry processing is then a natural fit.

  2. Naive calculations of geometric properties in latitude-longitude space, like area or arclength, are inherently inaccurate. Only spherical or geodesic computations provide correct results. While R's sf ecosystem solves this by wrapping Google's s2 library, and calling out to that whenever a longitude-latitude geometry is seen, implementing that approach in Julia is very challenging. Spherical computations address these problems effectively.

  3. Climate models and parametrizations often use different grid representations. Accurate mapping between these grids is virtually impossible in planar space due to the distortions created when projecting a plane onto a sphere. Working directly on the sphere makes it much easier to compute intersection areas between grid polygons, especially since they are simple polygons with 10 or fewer vertices. This capability will enable coupling between Oceananigans.jl and SpeedyWeather.jl for complete climate simulation!

JuliaGeo collaborator and author of GeoMakie.jl, and contributor to DocumenterVitepress.jl!

This speaker also appears in: