Skip to content

Use initial great-circle bearings in geodesic surface direction - #3770

Open
umrndem wants to merge 1 commit into
xarray-contrib:mainfrom
umrndem:fix/3733-geodesic-surface-direction
Open

umrndem wants to merge 1 commit into
xarray-contrib:mainfrom
umrndem:fix/3733-geodesic-surface-direction

Conversation

@umrndem

@umrndem umrndem commented Nov 18, 2026

Copy link
Copy Markdown

Fixes #3733.

Proposed changes

  • Compute the initial bearing from each cell's latitude and longitude to the target already selected by the surface-distance search. This uses the same spherical model as the geodesic distances.
  • Document the bearing convention and add regression tests at high latitude and across the antimeridian.

On the north-up test raster, the bearing from 60° N, 0° E to 61° N, 1° E was 135°. The patch returns approximately 25.78°.

Validation

  • The surface distance, proximity, and cost distance suites had 670 passes and 203 skips.
  • On a 256 × 256 terrain, 248 sampled bearings matched GeographicLib's spherical reference to within 0.000016° for both float32 and float64 inputs. Unreachable cells matched the distance mask.
  • Planar Dask results matched NumPy on both even and ragged chunks.

AI-assisted review

I reviewed the patch before submission. The project’s /validate workflow was used for the numerical and backend checks above. The changed geodesic path supports NumPy. CUDA checks were skipped because CUDA was unavailable locally.

@umrndem
umrndem marked this pull request as ready for review November 18, 2026 22:53

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Geodesic surface_direction scales index offsets by degrees, ignoring meridian convergence

1 participant