basemap does not draw coastlines for certain choice of map boundaries

Hi all,

I discovered recently that basmap does not draw the coastline contours
properly for some choice of map boundaries. Specifically,

from mpl_toolkits.basemap import Basemap
map =
Basemap(projection='cyl',llcrnrlat=-22.,urcrnrlat=22.,llcrnrlon=78.,urcrnrlon=168.,resolution='l')
map.drawcoastlines()

results in the coastline of continental Asia not being drawn (see
attachment bad_contours.png). On the other hand, even subtly changing
the latitude boundaries, to

map =
Basemap(projection='cyl',llcrnrlat=-22.001,urcrnrlat=22.001,llcrnrlon=78.,urcrnrlon=168.,resolution='l')

results in all the coastlines being drawn (see attachment
good_contours.png). I presume this is a bug?

Here is my system info:

Operating system: Linux 3.2.0-41-generic #66-Ubuntu SMP Thu Apr 25
03:27:11 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux

Matplotlib version: 1.1.0

Where I obtained matplotlib: SourceForge

Customizations to matplotlibrc: none

Thanks,

Sourish

good_contours.png

bad_contours.png

compose-unknown-contact.jpg

Sourish Basu

May 8, 2013 5:50 AM

Hi all,

I discovered recently that basmap does not draw the coastline contours
properly for some choice of map boundaries. Specifically,

from mpl_toolkits.basemap import
Basemap
map =
Basemap(projection=‘cyl’,llcrnrlat=-22.,urcrnrlat=22.,llcrnrlon=78.,urcrnrlon=168.,resolution=‘l’)
map.drawcoastlines()

results
in the coastline of continental Asia not being drawn (see
attachment
bad_contours.png). On the other hand, even subtly changing
the latitude boundaries, to

map =
Basemap(projection=‘cyl’,llcrnrlat=-22.001,urcrnrlat=22.001,llcrnrlon=78.,urcrnrlon=168.,resolution=‘l’)

results
in all the coastlines being drawn (see attachment
good_contours.png).
I presume this is a bug?

Sourish: Yes,
this is a bug. There are some corner cases in which the algorithm that
clips the coastline polygons to the map projection region fails. I’ve never been able to figure out exactly why. You solution (of slightly changing the map projection region) is the only thing I can recommend for now.

-Jeff

···

http://p.sf.net/sfu/neotech_d2d_mayMatplotlib-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/matplotlib-users