Matplotlib Mollweide/hammer Projection: Region Of Interest Only
I was wondering if there's a way to only show the region of interest from a plot based on Mollweide/Hammer projection in basemap (matplotlib). I am trying to set the plot-bounds ro
Solution 1:
From the documentation, both Hammer
and Mollweide
projections don't allow this as they print out entire world maps. Here's some code using Polyconic
projection, but it is bounded by straight lines. The trick here is to define the corner longitude and latitudes on creation.
from mpl_toolkits.basemapimportBasemapimport matplotlib.pyplotas plt
import numpy as np
my_map = Basemap(projection='poly', lat_0=0, lon_0=-160,
resolution = 'h', area_thresh = 0.1,
llcrnrlon=140, llcrnrlat=-60,
urcrnrlon=-100, urcrnrlat=60)
plt.figure(figsize=(16,12))
my_map.drawcoastlines()
my_map.drawcountries()
my_map.fillcontinents(color='coral', lake_color='aqua')
my_map.drawmapboundary(fill_color='aqua')
my_map.drawmeridians(np.arange(0, 360, 20))
my_map.drawparallels(np.arange(-90, 90, 10))
plt.show()
Result:
Note that this effectively shows less area than the one in the picture you provided.
Post a Comment for "Matplotlib Mollweide/hammer Projection: Region Of Interest Only"