Skip to content

Commit 32eb056

Browse files
committed
Fix flipped coastlines in pseudocylindrical projections
Solves GitHub issue #463. The bug appears in the `pyproj` transition from version 1.9.6 to 2.0.0, which corresponds when `pyproj` migrated from PROJ 4.x to PROJ 6.0.
1 parent 706f980 commit 32eb056

File tree

3 files changed

+10
-6
lines changed

3 files changed

+10
-6
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,8 @@ https://semver.org/spec/v2.0.0.html
1919
ETOPO, Shaded Relief) to be shown behind the map background when the
2020
map boundary is not initialised manually (solves issue [#577], thanks
2121
to @YilongWang).
22+
- Fix flipped coastlines with pseudocylindrical projections when `lon_0`
23+
is greater than 0 deg (solves issue [#463], thanks to @YilongWang).
2224

2325
## [1.3.8] - 2023-08-18
2426

@@ -1070,6 +1072,8 @@ https://github.com/matplotlib/basemap/issues/488
10701072
https://github.com/matplotlib/basemap/issues/487
10711073
[#476]:
10721074
https://github.com/matplotlib/basemap/pull/476
1075+
[#463]:
1076+
https://github.com/matplotlib/basemap/issues/463
10731077
[#461]:
10741078
https://github.com/matplotlib/basemap/issues/461
10751079
[#456]:

packages/basemap/src/mpl_toolkits/basemap/__init__.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -4181,8 +4181,8 @@ def warpimage(self,image="bluemarble",scale=None,**kwargs):
41814181
lonsr,latsr = self(x,y,inverse=True)
41824182
mask = ma.zeros((ny,nx,4),np.int8)
41834183
lon_0 = self.projparams['lon_0']
4184-
lonright = lon_0+180.
4185-
lonleft = lon_0-180.
4184+
lonright = lon_0 + 180. - 1E-10
4185+
lonleft = lon_0 - 180. + 1E-10
41864186
x1 = np.array(ny*[0.5*(self.xmax + self.xmin)],np.float64)
41874187
y1 = np.linspace(self.ymin, self.ymax, ny)
41884188
lons1, lats1 = self(x1,y1,inverse=True)

packages/basemap/src/mpl_toolkits/basemap/proj.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -195,8 +195,8 @@ def __init__(self,projparams,llcrnrlon,llcrnrlat,
195195
raise ValueError(_lower_left_out_of_bounds)
196196
elif self.projection in _pseudocyl:
197197
self._proj4 = pyproj.Proj(projparams)
198-
xtmp,urcrnry = self(projparams['lon_0'],90.)
199-
urcrnrx,xtmp = self(projparams['lon_0']+180.,0)
198+
xtmp, urcrnry = self(projparams['lon_0'], 90.)
199+
urcrnrx, xtmp = self(projparams['lon_0'] + 180. - 1E-10, 0)
200200
llcrnrx = -urcrnrx
201201
llcrnry = -urcrnry
202202
if self.ellipsoid and self.projection in ['kav7','eck4','mbtfpq']:
@@ -236,8 +236,8 @@ def __init__(self,projparams,llcrnrlon,llcrnrlat,
236236
if urcrnrx > 1.e20 or urcrnry > 1.e20:
237237
raise ValueError(_upper_right_out_of_bounds)
238238
elif self.projection in _pseudocyl:
239-
xtmp,urcrnry = self(projparams['lon_0'],90.)
240-
urcrnrx,xtmp = self(projparams['lon_0']+180.,0)
239+
xtmp, urcrnry = self(projparams['lon_0'], 90.)
240+
urcrnrx, xtmp = self(projparams['lon_0'] + 180. - 1E-10, 0)
241241
else:
242242
urcrnrx = urcrnrlon
243243
urcrnry = urcrnrlat

0 commit comments

Comments
 (0)