# Spherical Distance Rings Compared With WGS84

Research prepared on 2026-11-06 against `benton-tripp/azimuthalmap` commit `eda7a996e984322ccb76939a96b38c81470b0dd7`. The website's D3 azimuthal equidistant generator uses a sphere of radius 6,371 km. This investigation compares that spherical center-to-point distance model with shortest geodesics on the WGS84 ellipsoid. It does not reproduce screen pixels or measure off-center projection distortion.

## Reproduce

Run in a complete checkout of the Azimuthal Map repository:

```sh
python -m pip install -r static/research/requirements.txt
python static/research/compare-sphere-wgs84.py --out static/research
```

To reproduce an optional WGS84 numerical cross-check using PROJ:

```sh
python -m pip install pyproj==3.7.2
python static/research/compare-sphere-wgs84.py --out static/research --verify-pyproj
```

The optional check selects 100 evenly spaced principal sample records, computes WGS84 distances with `pyproj.Geod`, and reports the greatest difference from GeographicLib. The optional package is not needed to generate the data or figures.

When `static/js/map-generator.js` is present, the script verifies its Earth radius, D3 projection type, and scaling expression before running. It also checks the minified generator radius and projection type when that file is present. When the repository source is absent, the script reports this as a limitation in `source_validation` but still calculates the numeric results. The previously inspected baseline was the `main` commit noted above. Generated data are not evidence of a new source inspection when the repository is absent.

## Sample Design

- Seven starting latitudes: −80°, −60°, −30°, 0°, 30°, 60°, 80°.
- Eight WGS84 initial bearings: 0° to 315°, every 45°.
- Ten WGS84 distances: 1, 10, 100, 500, 1,000, 2,500, 5,000, 10,000, 15,000, 19,000 km.
- Three center longitudes: −120°, 0°, 120°. Because WGS84 is rotationally symmetric, these replicate 560 distinct latitude, bearing, and length geometries to test longitude handling.

The principal CSV group has 1,680 records, representing 560 geometries repeated at three longitudes. The generated destinations use GeographicLib 2.1's WGS84 direct solver. The inverse solver returns the reference distance for the same coordinate pair. This is a deterministic grid, not a random sample of places or user activities. No inference about global error probabilities or actual visitor routes is justified.

There are also 21 coincident, 21 antipodal, and 63 near-antipodal cases, retained as separate CSV groups and excluded from principal percentiles. The 1,785 CSV records use no visitor location or analytics data. City coordinates mentioned in the article are public representative values and are not in the generated principal sample.

## Definitions

- `sphere_km`: 6,371 km multiplied by the spherical central angle between the same numeric coordinates, calculated using a stable `atan2` formulation.
- `wgs84_km`: shortest ellipsoidal surface geodesic from GeographicLib `Geodesic.WGS84.Inverse`, in kilometers.
- `signed_error_km`: spherical minus WGS84 distance. Positive means the spherical distance is longer.
- `absolute_error_km`: absolute value of signed error.
- `percentage_error`: signed error divided by WGS84 distance, multiplied by 100; blank at zero distance.
- `planned_wgs84_km`: the input distance to the WGS84 direct solver, not a spherical angular distance.

Reported 95th percentiles are calculated over absolute errors using linear interpolation at position `(n - 1) × 0.95` of the sorted values. Repetition at three longitudes leaves the reported rounded statistics unchanged compared with the 560 unique geometries. The values are sample statistics, not tolerances applicable to all point pairs.

## Outputs

`compare-sphere-wgs84.py` generates the route CSV, summary JSON, and both SVG figures. Each SVG has embedded title and description text and a link to a full-size image in the article. The `source_validation` field in the JSON records whether the source was available to the script during that specific execution; it is not part of the distance calculations.

Source references: [NOAA WGS84 ellipsoid](https://vdatum.noaa.gov/docs/datums.html), [GeographicLib geodesics](https://geographiclib.sourceforge.io/html/python/geodesics.html), [D3 azimuthal projections](https://d3js.org/d3-geo/azimuthal), and [PROJ ellipsoidal azimuthal equidistant projection](https://proj.org/en/stable/operations/projections/aeqd.html).
