matplotlib / basemap

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

Polygons and tissot across the edge in Mollweide: #378

Open rbiswas4 opened 7 years ago

rbiswas4 commented 7 years ago

There seems to be a known problem with tissot and Polygon in the 'Mollweide' projection with basemap when these objects cross the 'limb' (180 degree line if the central longitude is 0. which is both the East and West edges of the map). The obvious solution is of course to split this into two polygons split at the limb. I realized that this was actually already available in examples (for tissots): https://github.com/matplotlib/basemap/blob/master/examples/allskymap.py and am wondering if there are plans to eventually replace Basemap.tissot or if there are deeper problems with this.

rbiswas4 commented 7 years ago

BTW: I checked the example code and found that it works correctly depending on the number of points:

For example:

fig, ax = plt.subplots()#1, 2)
#ax = axx[0]
m = AllSkyMap(projection='moll', lon_0=0., lat_0=0.,
            ax=ax)
_ = m.drawparallels(np.arange(-91.,91.,20.))
_ = m.drawmeridians(np.arange(-180., 181., 60.), labels=[1, 0, 0, 1], labelstyle='+/-')
poly = m.tissot(180., 30., 4., 10, ax=ax, **dict(linewidth=0, linestyle=None, edgecolor='w' ))

produces:

unknown-2

While bumping the number of points to 100 in the argument of tissot produces:

fig, ax = plt.subplots()#1, 2)
#ax = axx[0]
m = AllSkyMap(projection='moll', lon_0=0., lat_0=0.,
            ax=ax)
_ = m.drawparallels(np.arange(-91.,91.,20.))
_ = m.drawmeridians(np.arange(-180., 181., 60.), labels=[1, 0, 0, 1], labelstyle='+/-')
poly = m.tissot(180., 30., 4., 100, ax=ax, **dict(linewidth=0, linestyle=None, edgecolor='w' ))

unknown-1 However, to get this right without any constraints on linewidth, I need to bump up the number of points (and it works for 1000).