Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -1730,12 +1730,20 @@ def y_limits(self):


class LambertCylindrical(_RectangularProjection):
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we actually create a different class GallPeters with a fixed lat_ts=45 and/or a CylindricalEqualArea superclass that takes the new keyword argument. It looks like the Lambert version is specifically for lat_ts=0
https://proj.org/en/stable/operations/projections/cea.html

def __init__(self, central_longitude=0.0, globe=None):
def __init__(self, central_longitude=0.0, globe=None,
latitude_true_scale=0.0):
globe = globe or Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS)
proj4_params = [('proj', 'cea'), ('lon_0', central_longitude),
('lat_ts', latitude_true_scale),
('to_meter', math.radians(1) * (
globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS))]
super().__init__(proj4_params, 180, math.degrees(1), globe=globe)
stretch_factor = np.cos(np.deg2rad(latitude_true_scale)) ** 2
super().__init__(
proj4_params,
180 * np.sqrt(stretch_factor),
math.degrees(1) / np.sqrt(stretch_factor),
globe=globe,
)


class LambertConformal(Projection):
Expand Down
3 changes: 3 additions & 0 deletions lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,9 @@
ccrs.AzimuthalEquidistant,
ccrs.LambertConformal,
ccrs.LambertCylindrical,
pytest.param((ccrs.LambertCylindrical, dict(latitude_true_scale=45)),
id='GallPeters'),
ccrs.LambertCylindrical,
ccrs.Mercator,
ccrs.Miller,
ccrs.Mollweide,
Expand Down
Loading