Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions Changelog
Original file line number Diff line number Diff line change
@@ -1,4 +1,10 @@
version 1.0.3 (not yet released)
* clip coastlines for nplaea,npaeqd,splaea,spaeqd in stereographic
coordinates to avoid S. America disappearing in some south polar
plots.
* add 'round' keyword to Basemap.__init__ for pole-centered
projections to make them round (clipped at boundinglat) instead
of square.
* fix broken daynight terminator function.
* added kav7 (Kavrayskiy VII) and eck4 (Eckert IV) projections
(https://github.com/matplotlib/basemap/issues/9).
Expand Down
19 changes: 11 additions & 8 deletions examples/polarmaps.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

# illustrates special-case polar-centric projections.

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

Expand All @@ -26,15 +26,17 @@
# showing all four polar projections.
for hem in ['North','South']:
if hem == 'South':
lon_0 = 130.
lon_0 = -130.
lon_0_ortho = lon_0 - 180.
lat_0 = -90.
bounding_lat = -20.
# Lambert Azimuth bounding lat must not extend into opposite hem.
bounding_lat = -0.01
elif hem == 'North':
lon_0 = -90.
lon_0 = 130.
lon_0_ortho = lon_0
lat_0 = 90.
bounding_lat = 20.
# Lambert Azimuth bounding lat must not extend into opposite hem.
bounding_lat = 0.01
# loop over projections, one for each panel of the figure.
fig = plt.figure(figsize=(8,8))
npanel = 0
Expand All @@ -51,17 +53,18 @@
resolution='c',area_thresh=10000.,lat_0=lat_0,lon_0=lon_0_ortho)
else:
m = Basemap(boundinglat=bounding_lat,lon_0=lon_0,\
resolution='c',area_thresh=10000.,projection=projection)
resolution='c',area_thresh=10000.,projection=projection,round=True)
# compute native map projection coordinates for lat/lon grid.
x,y = m(*np.meshgrid(lons,lats))
ax = fig.add_subplot(2,2,npanel)
# make filled contour plot.
cs = m.contourf(x,y,etopo,20,cmap=plt.cm.jet)
cs = m.contourf(x,y,etopo,np.linspace(-7500,4500,41),cmap=cm.GMT_haxby)
# draw coastlines.
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-80.,90,20.))
m.drawmeridians(np.arange(0.,360.,60.))
#labels = [l,r,t,b]
m.drawmeridians(np.arange(0.,340.,30.),labels=[1,1,1,1],fontsize=7)
# draw boundary around map region.
m.drawmapboundary()
# draw title.
Expand Down
70 changes: 70 additions & 0 deletions examples/round.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
# make plots of etopo bathymetry/topography data on
# various map projections, drawing coastlines, state and
# country boundaries, filling continents and drawing
# parallels/meridians

# illustrates special-case polar-centric projections.

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

# read in topo data (on a regular lat/lon grid)
# longitudes go from 20 to 380.
etopo = np.loadtxt('etopo20data.gz')
lons = np.loadtxt('etopo20lons.gz')
lats = np.loadtxt('etopo20lats.gz')

print 'min/max etopo20 data:'
print etopo.min(),etopo.max()

# these are the 4 polar projections
projs = ['laea','stere','aeqd','ortho'] # short names
# long names
projnames = ['Lambert Azimuthal Equal Area','Stereographic','Azimuthal Equidistant','Orthographic']
# loop over hemispheres, make a 4-panel plot for each hemisphere
# showing all four polar projections.
for hem in ['North','South']:
if hem == 'South':
lon_0 = 130.
lon_0_ortho = lon_0 - 180.
lat_0 = -90.
bounding_lat = -1.
elif hem == 'North':
lon_0 = -90.
lon_0_ortho = lon_0
lat_0 = 90.
bounding_lat = 1.
# loop over projections, one for each panel of the figure.
fig = plt.figure(figsize=(8,8))
npanel = 0
for proj,projname in zip(projs,projnames):
npanel = npanel + 1
if hem == 'South':
projection = 'sp'+proj
elif hem == 'North':
projection = 'np'+proj
# setup map projection
# centered on Australia (for SH) or US (for NH).
if proj == 'ortho':
m = Basemap(projection='ortho',
resolution='c',area_thresh=10000.,lat_0=lat_0,lon_0=lon_0_ortho)
else:
m = Basemap(boundinglat=bounding_lat,lon_0=lon_0,\
resolution='c',area_thresh=10000.,projection=projection,round=True)
# compute native map projection coordinates for lat/lon grid.
x,y = m(*np.meshgrid(lons,lats))
ax = fig.add_subplot(2,2,npanel)
# make filled contour plot.
cs = m.contourf(x,y,etopo,20,cmap=plt.cm.jet)
# draw coastlines.
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-80.,90,20.))
m.drawmeridians(np.arange(0.,360.,60.))
# draw boundary around map region.
m.drawmapboundary()
# draw title.
plt.title(hem+' Polar '+projname,y=1.05,fontsize=12)
print 'plotting '+hem+' Polar '+projname+' basemap ...'
plt.show()
Loading