Skip to content

Fixes GEOSException when plotting with projection with nonzero central_longitude - #1811

Open
Sevans711 wants to merge 2 commits into
mainfrom
sevans/fix-central_longitude-GEOSException
Open

Sevans711 wants to merge 2 commits into
mainfrom
sevans/fix-central_longitude-GEOSException

Conversation

@Sevans711

Copy link
Copy Markdown
Collaborator

Closes #1795

Overview

Swaps to an algebraic transformation (node_lon = (node_lon - central_longitude + 180.0) % 360.0 - 180.0) to shift longitudes, instead of using cartopy.crs.PlateCarree(...).transform_points(...), to avoid cartopy.crs giving NaNs at the poles, which is what originally triggered #1795.

test_plot_with_nonzero_central_longitude() serves as a regression test for this. It loops across many cartopy projections using the new _cartopy_projections() helper function, which I just copy-pasted it directly from the uxarray_debug_utils I've been accumulating while developing uxarray. I know this helper function has more functionality than what is actually being used here, but rather than trim it down I think it is easier to just keep the full version for now, since it is just in the test suite and not user-facing?

Along the way, discovered a bug when applying _central_longitude_of() to ObliqueMercator projections. The previous behavior was to always silently return 0, ignoring any actually-input central_longitude. This PR fixes _central_longitude_of() to instead handle this case properly (regression test: test_central_longitude_of_for_all_nonlocal_projections()), and also to emit a warning instead of silently returning 0 when central_longitude cannot be determined (updated test_central_longitude_of_handles_cartopy_026_platecarree() accordingly, to check for such a warning).

PR Checklist

General

  • An issue is created and linked
  • Added appropriate labels (if your uxarray repo permissions allow it)
  • Filled out Overview and Expected Usage (if applicable) sections

Testing & Benchmarking

  • There is adequate test coverage of changes from this PR (add new tests if needed)
  • [N/A] If this PR could affect performance, ran ASV benchmarks and confirmed they show expected behavior (add a new benchmark if necessary)

Documentation and Examples

  • [N/A] Docstrings updated with any function changes, and included in all new functions
  • [N/A] User (public) functions added to docs/api.rst; internal (private) function names start with an underscore (_)
  • [N/A] If touched any notebook files, cleared the output of all cells before committing
  • [N/A] If added new notebook files, put into appropriate directories and referenced in appropriate files

AI Disclosure

AI Usage: Some Claude to help with debugging, some GitHub Copilot's inline code suggestions.

  • I have tested and take responsibility for all AI-generated content in my PR.

@Sevans711 Sevans711 added bug Something isn't working visualization Plotting or other visualizations labels Oct 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bug Something isn't working visualization Plotting or other visualizations

Projects

None yet

Development

Successfully merging this pull request may close these issues.

GEOSException in uxarr.plot(..., projection=cartopy.crs.Robinson(central_longitude=...))

1 participant