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
65 changes: 65 additions & 0 deletions lib/cartopy/crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -3089,6 +3089,71 @@ def y_limits(self):
return self._y_limits


class ObliqueMercator(Projection):
"""
An Oblique Mercator projection.

"""
_wrappable = True

def __init__(self, central_longitude=0.0, central_latitude=0.0,
false_easting=0.0, false_northing=0.0,
scale_factor=1.0, azimuth=0.0, globe=None):
"""
Parameters
----------
central_longitude: optional
The true longitude of the central meridian in degrees.
Defaults to 0.
central_latitude: optional
The true latitude of the planar origin in degrees. Defaults to 0.
false_easting: optional
X offset from the planar origin in metres. Defaults to 0.
false_northing: optional
Y offset from the planar origin in metres. Defaults to 0.
scale_factor: optional
Scale factor at the central meridian. Defaults to 1.
azimuth: optional
Azimuth of centerline clockwise from north at the center point of
the centre line. Defaults to 0.

bjlittle marked this conversation as resolved.
Show resolved Hide resolved
globe: optional
An instance of :class:`cartopy.crs.Globe`. If omitted, a default
globe is created.

Notes
-----
The 'Rotated Mercator' projection can be achieved using Oblique
Mercator with `azimuth` ``=90``.

"""

proj4_params = [('proj', 'omerc'), ('lonc', central_longitude),
('lat_0', central_latitude), ('k', scale_factor),
('x_0', false_easting), ('y_0', false_northing),
('alpha', azimuth), ('units', 'm')]

super().__init__(proj4_params, globe=globe)

self.threshold = 1e4

@property
def boundary(self):
x0, x1 = self.x_limits
y0, y1 = self.y_limits
return sgeom.LinearRing([(x0, y0), (x0, y1),
(x1, y1), (x1, y0),
(x0, y0)])

@property
def x_limits(self):
return (-2e7, 2e7)

@property
def y_limits(self):
return (-1e7, 1e7)
bjlittle marked this conversation as resolved.
Show resolved Hide resolved


class _BoundaryPoint:
def __init__(self, distance, kind, data):
"""
Expand Down
1 change: 1 addition & 0 deletions lib/cartopy/mpl/gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
cartopy.crs.LambertConformal,
cartopy.crs.TransverseMercator,
cartopy.crs.Gnomonic,
cartopy.crs.ObliqueMercator,
)


Expand Down