Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Oblique Mercator class #2096

Merged
merged 11 commits into from
Mar 10, 2023
Merged

Oblique Mercator class #2096

merged 11 commits into from
Mar 10, 2023

Conversation

trexfeathers
Copy link
Contributor

@trexfeathers trexfeathers commented Oct 19, 2022

Rationale

Iris users are requesting (SciTools/iris#4830) support for the Oblique Mercator projection, in line with the CF Conventions. This will allow them to quickly and easily plot data from NetCDF files that use this projection.

(Code largely copied from TransverseMercator, with appropriate modifications).

Implications

New feature, no other expected implications. Closes #1618.

To-do:

Usage example

from cartopy import crs as ccrs
from matplotlib import pyplot as plt

projection = ccrs.ObliqueMercator()
ax = plt.axes(projection=projection)
ax.coastlines()
ax.gridlines()
plt.show()

oblique_mercator

@trexfeathers
Copy link
Contributor Author

trexfeathers commented Oct 19, 2022

I need help!

Solution: f9b99ca

Running with the following arguments causes some weird coastline 'folding', which I haven't seen anywhere else in Cartopy. Any ideas for cause and solution are welcome.

from cartopy import crs as ccrs
from matplotlib import pyplot as plt

projection = ccrs.ObliqueMercator(
    central_longitude=-59,
    central_latitude=-22,
    false_easting=-25000,
    false_northing=-25000,
    scale_factor=1,
    azimuth=90,
)

ax = plt.axes(projection=projection)
ax.coastlines()
ax.gridlines()
plt.show()

oblique_mercator_fold

lib/cartopy/crs.py Outdated Show resolved Hide resolved
@dopplershift
Copy link
Contributor

I think setting more appropriate values for x_limits and y_limits might help automatically block out the folding? Essentially those values are the valid ranges for those coordinates in projected space.

@trexfeathers
Copy link
Contributor Author

I think setting more appropriate values for x_limits and y_limits might help automatically block out the folding? Essentially those values are the valid ranges for those coordinates in projected space.

Thanks @dopplershift, we did some experiments but the limits made no difference to the overlapping coastlines. Reasonably happy with the current iteration, having solved both confusions.

@trexfeathers trexfeathers self-assigned this Feb 22, 2023
lib/cartopy/tests/crs/test_oblique_mercator.py Outdated Show resolved Hide resolved
lib/cartopy/tests/crs/test_oblique_mercator.py Outdated Show resolved Hide resolved
lib/cartopy/tests/crs/test_oblique_mercator.py Outdated Show resolved Hide resolved
lib/cartopy/tests/mpl/test_mpl_integration.py Outdated Show resolved Hide resolved
@trexfeathers
Copy link
Contributor Author

@SciTools/cartopy-devs any ideas what I've done to cause the docs failure?

@trexfeathers trexfeathers marked this pull request as ready for review March 6, 2023 16:43
@trexfeathers trexfeathers removed their assignment Mar 6, 2023
@rcomer
Copy link
Member

rcomer commented Mar 6, 2023

@trexfeathers I think it wasn’t you pydata/pydata-sphinx-theme#1226

@trexfeathers trexfeathers reopened this Mar 7, 2023
@trexfeathers
Copy link
Contributor Author

@trexfeathers I think it wasn’t you pydata/pydata-sphinx-theme#1226

@bjlittle bjlittle self-assigned this Mar 9, 2023
Copy link
Member

@bjlittle bjlittle left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@trexfeathers Thanks for this awesome contribution, much appreciated.

Just some super minor comments to service, and then we can bank this new CRS loveliness 😄

lib/cartopy/crs.py Outdated Show resolved Hide resolved
lib/cartopy/crs.py Show resolved Hide resolved
lib/cartopy/tests/crs/test_oblique_mercator.py Outdated Show resolved Hide resolved
@bjlittle bjlittle merged commit 2a6d1e6 into SciTools:main Mar 10, 2023
@bjlittle
Copy link
Member

@trexfeathers Thanks again... now it's time to oblique my mercator!

Lovely contribution, cheers 🍻

@QuLogic QuLogic added this to the 0.22 milestone Mar 11, 2023
@QuLogic
Copy link
Member

QuLogic commented Mar 11, 2023

ObliqueMercator is not in the projections list because you forgot to run make projection.

@bjlittle
Copy link
Member

@QuLogic Thanks, see #2146 👍

@trexfeathers
Copy link
Contributor Author

Forgot to say: thanks to @ESadek-MO and @scottrobinson02 for their help on this project ❤

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

Add Oblique Mercator
6 participants