matplotlib / basemap

Plot on map projections (with coastlines and political boundaries) using matplotlib
MIT License
775 stars 392 forks source link

Broken Basemap rotpole projection #376

Open rkouznetsov opened 6 years ago

rkouznetsov commented 6 years ago

Initally posted by a mistake to matplotlib/matplotlib https://github.com/matplotlib/matplotlib/issues/9541 Here seems to be more relevant..

Bug report

Bug summary

Basemap can't plot rotated-pole maps that cross rotated-grid's 0-th meridian

Code for reproduction Here is a simple code that produce two maps for non-rotated grid (zero-rotation). One does not cross Greenwich meridian another one does.

# Paste your code here
#
#
#!/usr/bin/python
import matplotlib as mpl
mpl.use('AGG')

import matplotlib.pyplot as plt
import numpy as np
from mpl_toolkits.basemap import Basemap
import os

figname="okay.png"
fig = plt.figure()
bmap = Basemap(projection='rotpole',
       llcrnrx=0, urcrnry=15,
       urcrnrx=25, llcrnry=-15,
       lon_0 = 0,
       o_lon_p = 0.,
       o_lat_p = 90.,
       resolution='c')

bmap.drawmapboundary(fill_color='aqua')
bmap.fillcontinents(color='coral',lake_color='aqua')
bmap.drawcoastlines(linewidth=0.5)
bmap.drawparallels(np.arange(-20,20,10.))
bmap.drawmeridians(np.arange(-40,40,10.))

mpl.pyplot.savefig(figname)

figname="broken.png"
fig.clf()

bmap = Basemap(projection='rotpole',
       llcrnrx=-25, urcrnry=15,
       urcrnrx=25, llcrnry=-15,
       lon_0 = 0,
       o_lon_p = 0.,
       o_lat_p = 90.,
       resolution='c')

bmap.drawmapboundary(fill_color='aqua')
bmap.fillcontinents(color='coral',lake_color='aqua')
bmap.drawcoastlines(linewidth=0.5)
bmap.drawparallels(np.arange(-20,20,10.))
bmap.drawmeridians(np.arange(-40,40,10.))

mpl.pyplot.savefig(figname)

Actual outcome Here are two maps.. The second one is obviously broken. okay broken

Matplotlib version

Default Ubuntu 16.04.3 LTS installation