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

LambertConformal projection maximal longitude extent #1665

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

leonard-seydoux
Copy link

Rationale

The previous version of LambertConformal projection does not allow to control the longitudinal extent of the map (it was hardcoded at 180º). It was only possible to use the set_extent method of a GeoAxes instance, resulting in vertical (or horizontal) axes boundaries. Yet, a Lambert conformal projection can have arbitrary longitude extent. This version implements a control on this extent.

Implications

Being able to control the longitude extent of a GeoAxes instance with a single keyword argument added to LambertConformal.

Checklist

  • I have read and signed the Contributor Licence Agreement (CLA) just before proposing this pull request.

  • New feature: keyword argument longitude_extent added to the LambertConformal CRS. By default, the behavior of he projection is unchanged (i.e. longitude_extent=180). When specified, the extent of the GeoAxes with LambertConformal projection with have axes boundaries drawn within the range (central_longitude - longitude_extent, central_longitude + longitude_extent).

  • The docstring was updated accordingly.

Example use (compare with and without controlling the longitude extent)

from cartopy import crs, feature
from matplotlib import pyplot as plt

# create figure
fig = plt.figure()

# original behaviour
proj = crs.LambertConformal(central_longitude=-100)
ax = fig.add_subplot(121, projection=proj)
ax.add_feature(feature.LAND, facecolor="0.9")
ax.gridlines()
ax.set_title("Default extent")

# new possibility
proj = crs.LambertConformal(central_longitude=-100, longitude_extent=60)
ax = fig.add_subplot(122, projection=proj)
ax.add_feature(feature.LAND, facecolor="0.9")
ax.gridlines()
ax.set_title("Controled extent")

# show maps
plt.show()

map_example

@dopplershift
Copy link
Contributor

This seems reasonable since you can't replicate this by calling set_extent(). Can you add a test? Maybe checking the boundary when you pass longitude_extent?

@leonard-seydoux
Copy link
Author

Sure, but I do not see what test you have in mind?

@marqh
Copy link
Member

marqh commented Oct 14, 2021

hello @leonard-seydoux

you can see the current testing of the
lambert conformal projection
in
https://github.com/SciTools/cartopy/blob/master/lib/cartopy/tests/crs/test_lambert_conformal.py

perhaps you could consider a new test case which explicitly uses this new longitude_extent parameter, verify that it exists and check the resulting longitude_extent as suggested by @dopplershift

does this pattern seem suitable for adoption into this PR?

marqh

@CLAassistant
Copy link

CLAassistant commented Apr 8, 2024

CLA assistant check
All committers have signed the CLA.

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.

4 participants