Jeff - Thanks. Is there an easy way you know of to detect when there are no continent boundaries? I'm making these maps automatically, and so will not have the luxury of examining them to see where they are.
--Mike On May 10, 2010, at 2:57 PM, Jeff Whitaker wrote: > On 5/10/10 2:21 PM, Michael Hearne wrote: >> I have found a (possible) bug in Basemap - when using >> basemap.fillcontinents(), I see the chosen continent color only when the map >> I create includes some ocean. If I am in the interior of a continent (I've >> tested with North America and Asia), the continent color is white. >> > > Michael: If there are no continent boundaries inside the map projection > region, basemap does not draw anything (hence you see the axis background > color). In that case, you should just set the axis background color to > whatever you wanted the continent color to be. > > -Jeff >> A code sample is below. My version information: >> Basemap: 0.99.4 >> Matplotlib: 0.99.1.1 >> numpy: 1.4.0 >> Python: 2.6.4 >> >> To replicate my results, please try the following: >> ./maptest.py 37.894507 -121.816406 #map center is somewhere in the Bay Area >> in California >> ./maptest.py 41.880332 -100.47821 #map center is somewhere in Nebraska >> >> The script creates a file called "output.png" in the calling directory. In >> the California case, I see the ocean as blue, and the land as a sort of >> annoying salmon color. In the Nebraska case, I see white with blue denoting >> the various rivers and lakes in the area. >> >> Am I mis-using the basemap method calls in some way? >> >> Thanks, >> >> Mike >> >> -------------------------------------------------------------------- >> #!/usr/bin/env python >> >> import matplotlib >> #use the non-interactive matplotlib setting >> matplotlib.use('agg') >> from mpl_toolkits.basemap import Basemap >> import numpy as np >> from pylab import * >> import sys >> >> clat = float(sys.argv[1]) >> clon = float(sys.argv[2]) >> >> figwidth = 5.4 >> >> >> bounds = (clon-4, clon+4, clat-4, clat+4) >> dx = (bounds[1] - bounds[0])*111191 * np.cos(clat * np.pi/180) >> dy = (bounds[3] - bounds[2])*111191 >> aspect = dy/dx >> figheight = aspect * figwidth >> >> fig = figure(figsize=(figwidth,figheight),edgecolor='g',facecolor='g') >> ax1 = fig.add_axes([0,0,1.0,1.0]) >> mapcontour = Basemap(llcrnrlon=bounds[0],llcrnrlat=bounds[2], >> urcrnrlon=bounds[1],urcrnrlat=bounds[3], >> resolution='h',projection='merc',lat_ts=clat) >> water_color = [.47,.60,.81] >> mapcontour.drawrivers(color=water_color) >> mapcontour.drawcountries(color='k',linewidth=2.0) >> mapcontour.drawcoastlines() >> mapcontour.fillcontinents(color=[1.0,0.8,0.8],lake_color=water_color) >> >> plt.savefig('output.png') >> -------------------------------------------------------------------- >> >> >> ------------------------------------------------------------------------------ >> >> _______________________________________________ >> Matplotlib-users mailing list >> Matplotlib-users@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/matplotlib-users >> > ------------------------------------------------------------------------------ _______________________________________________ Matplotlib-users mailing list Matplotlib-users@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/matplotlib-users