Skip to content

Commit 2d5cf5f

Browse files
committed
Update PlateCarree to use latlon
Implement the shift previously enabled with lon_0 using the prime meridian (pm) argument.
1 parent accdf78 commit 2d5cf5f

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

lib/cartopy/crs.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1352,10 +1352,7 @@ def _ellipse_boundary(semimajor=2, semiminor=1, easting=0, northing=0, n=201):
13521352
class PlateCarree(_CylindricalProjection):
13531353
def __init__(self, central_longitude=0.0, globe=None):
13541354
globe = globe or Globe(semimajor_axis=WGS84_SEMIMAJOR_AXIS)
1355-
proj4_params = [('proj', 'eqc'), ('lon_0', central_longitude),
1356-
('to_meter', math.radians(1) * (
1357-
globe.semimajor_axis or WGS84_SEMIMAJOR_AXIS)),
1358-
('vto_meter', 1)]
1355+
proj4_params = [('proj', 'latlong'), ('pm', central_longitude)]
13591356
x_max = 180
13601357
y_max = 90
13611358
# Set the threshold around 0.5 if the x max is 180.
@@ -1385,8 +1382,8 @@ def _bbox_and_offset(self, other_plate_carree):
13851382
central longitudes. No checking of this is done.
13861383
13871384
"""
1388-
self_lon_0 = self.proj4_params['lon_0']
1389-
other_lon_0 = other_plate_carree.proj4_params['lon_0']
1385+
self_lon_0 = self.proj4_params['pm']
1386+
other_lon_0 = other_plate_carree.proj4_params['pm']
13901387

13911388
lon_0_offset = other_lon_0 - self_lon_0
13921389

@@ -1414,7 +1411,8 @@ def quick_vertices_transform(self, vertices, src_crs):
14141411
if return_value is None and isinstance(src_crs, PlateCarree):
14151412
self_params = self.proj4_params.copy()
14161413
src_params = src_crs.proj4_params.copy()
1417-
self_params.pop('lon_0'), src_params.pop('lon_0')
1414+
self_params.pop('pm')
1415+
src_params.pop('pm')
14181416

14191417
xs, ys = vertices[:, 0], vertices[:, 1]
14201418

@@ -1440,6 +1438,12 @@ def quick_vertices_transform(self, vertices, src_crs):
14401438

14411439
return return_value
14421440

1441+
def as_geodetic(self):
1442+
from pyproj import CRS as P_CRS
1443+
d = self.geodetic_crs.to_json_dict()
1444+
d['datum'].pop('prime_meridian', None)
1445+
return CRS(P_CRS.from_json_dict(d))
1446+
14431447

14441448
class TransverseMercator(Projection):
14451449
"""

0 commit comments

Comments
 (0)