from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
import numpy as np
#from matplotlib.patches import Polygon
#from matplotlib.collections import PatchCollection
#from matplotlib.patches import PathPatch
from pylab import rcParams
%matplotlib inline
rcParams['figure.figsize'] = (8,6)
kav7 Kavrayskiy VII
tmerc Transverse Mercator
eck4 Eckert IV
npaeqd North-Polar Azimuthal Equidistant
stere Stereographic
ortho Orthographic
cea Cylindrical Equal Area
robin Robinson
poly Polyconic
cyl Cylindrical Equidistant
rotpole Rotated Pole
nplaea North-Polar Lambert Azimuthal
vandg van der Grinten
nsper Near-Sided Perspective
gall Gall Stereographic Cylindrical
splaea South-Polar Lambert Azimuthal
spstere South-Polar Stereographic
merc Mercator
eqdc Equidistant Conic
laea Lambert Azimuthal Equal Area
geos Geostationary
aeqd Azimuthal Equidistant
hammer Hammer
sinu Sinusoidal
moll Mollweide
gnom Gnomonic
mbtfpq McBryde-Thomas Flat-Polar Quartic
cass Cassini-Soldner
lcc Lambert Conformal
npstere North-Polar Stereographic
spaeqd South-Polar Azimuthal Equidistant
omerc Oblique Mercator
mill Miller Cylindrical
aea Albers Equal Area
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
my_map = Basemap(projection='kav7',lon_0=140,resolution='c')
my_map.drawcoastlines()
my_map.drawparallels(np.arange(-80.,81.,20.))
my_map.drawmeridians(np.arange(-180.,181.,20 ))
plt.title('kav7 Kavrayskiy VII')
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'i' means use intermediate resolution coastlines.
# lon_0, lat_0 are the central longitude and latitude of the projection.
m = Basemap(llcrnrlon=-179,llcrnrlat=-80,urcrnrlon=179,urcrnrlat=80,
resolution='l',projection='tmerc',lon_0=150,lat_0=-24)
my_map.drawcoastlines()
my_map.drawparallels(np.arange(-80.,81.,20.))
my_map.drawmeridians(np.arange(-180.,181.,20 ))
plt.title('tmerc Transverse Mercator')
plt.show()
# make sure the value of resolution is a lowercase L,
# for 'low', not a numeral 1
my_map = Basemap(projection='eck4', lat_0=-24, lon_0=150,
resolution='l', area_thresh=1000.0)
my_map.drawcoastlines()
my_map.drawparallels(np.arange(-80.,81.,20.))
my_map.drawmeridians(np.arange(-180.,181.,20 ))
plt.title('eck4 Eckert IV')
plt.show()
# make sure the value of resolution is a lowercase L,
# for 'low', not a numeral 1
# setup stereographic basemap.
# lat_ts is latitude of true scale.
# lon_0,lat_0 is central point.
m = Basemap(width=36000000,height=16000000,
resolution='l',projection='stere',\
lat_ts=-25,lat_0=-24,lon_0=154.)
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawcoastlines()
plt.title('stere Stereographic')
plt.show()
# make sure the value of resolution is a lowercase L,
# for 'low', not a numeral 1
# lon_0, lat_0 are the center point of the projection.
# resolution = 'l' means use low resolution coastlines.
m = Basemap(projection='ortho',lon_0=150,lat_0=-24,resolution='l')
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawcoastlines()
plt.title('ortho Orthographic')
plt.show()
m = Basemap(projection='cea',llcrnrlat=-90,urcrnrlat=90,\
llcrnrlon=-180,urcrnrlon=180,resolution='l')
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawcoastlines()
plt.title('cea Cylindrical Equal Area')
plt.show()
# lon_0 is central longitude of projection.
m = Basemap(projection='robin',lon_0=150,resolution='l')
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawcoastlines()
plt.title('robin Robinson')
plt.show()
m = Basemap(llcrnrlon=-35.,llcrnrlat=-30,urcrnrlon=180.,urcrnrlat=50.,\
resolution='l',area_thresh=1000.,projection='poly',\
lat_0=0.,lon_0=120.)
m.drawcoastlines()
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
plt.title('poly Polyconic')
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
m = Basemap(projection='cyl',llcrnrlat=-90,urcrnrlat=90,\
llcrnrlon=-30,urcrnrlon=330,resolution='l')
m.drawparallels(np.arange(-80.,81.,20.))
m.drawmeridians(np.arange(-180.,181.,20.))
m.drawcoastlines()
plt.title('cyl Cylindrical Equidistant')
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='mbtfpq',lon_0=150,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("mbtfpq McBryde-Thomas Flat Polar Quartic Projection")
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='rotpole',llcrnrlon=-80.,llcrnrlat=-80,urcrnrlon=330.,urcrnrlat=80.,\
lon_0=150,o_lat_p=-24, o_lon_p=150, resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("rotpole Rotated Pole")
plt.show()
# setup north polar stereographic basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts
# (latitude of true scale) is pole.
m = Basemap(projection='npstere',boundinglat=10,lon_0=154,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("npstere North-Polar Stereographic")
plt.show()
# setup north polar lambert azimuthal basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0.
m = Basemap(projection='nplaea',boundinglat=10,lon_0=154,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("nplaea Polar Lambert Azimuthal Projection")
plt.show()
# setup north polar lambert azimuthal basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0.
m = Basemap(projection='splaea',boundinglat=-10,lon_0=154,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("splaea Polar Lambert Azimuthal Projection")
plt.show()
# setup north polar stereographic basemap.
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts
# (latitude of true scale) is pole.
m = Basemap(projection='spstere',boundinglat=-10,lon_0=154,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("spstere South-Polar Stereographic")
plt.show()
# The longitude lon_0 is at 6-o'clock, and the
# latitude circle boundinglat is tangent to the edge
# of the map at lon_0. Default value of lat_ts
# (latitude of true scale) is pole.
m = Basemap(projection='vandg',lon_0=154,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("vandg van der Grinten Projection")
plt.show()
# lon_0, lat_0 are the center point of the projection.
# satellite_height is the altitude of the camera.
# resolution = 'l' means use low resolution coastlines.
h = 35786.
m = Basemap(projection='nsper',lon_0=154,lat_0=0,
satellite_height=h*1000.,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("nsper Near-Sided Perspective Projection")
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='gall',llcrnrlat=-90,urcrnrlat=90,\
llcrnrlon=-30,urcrnrlon=330,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("gall Gall Stereographic Projection")
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# lat_ts is the latitude of true scale.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='merc',llcrnrlat=-80,urcrnrlat=80,\
llcrnrlon=-30,urcrnrlon=330,lat_ts=20,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("merc Mercator Projection")
plt.show()
# setup equidistant conic basemap.
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
# lon_0,lat_0 is central point.
# resolution = 'l' for low-resolution coastlines.
m = Basemap(width=12000000,height=9000000,
resolution='l',projection='eqdc',\
lat_1=0,lat_2=-40,lat_0=-24,lon_0=140.)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("eqdc Equidistant Conic Projection Projection")
plt.show()
# setup lambert azimuthal equal area basemap.
# lat_ts is latitude of true scale.
# lon_0,lat_0 is central point.
m = Basemap(width=12000000,height=8000000,
resolution='l',projection='laea',\
lat_ts=-20,lat_0=-24,lon_0=140.)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("laea Lambert Azimuthal Equal Area Projection")
plt.show()
# lon_0 is the central longitude of the projection.
# resolution = 'l' means use low resolution coastlines.
# optional parameter 'satellite_height' may be used to
# specify height of orbit above earth (default 35,786 km).
m = Basemap(projection='geos',lon_0=140,resolution='l')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("geos Geostationary Projection")
plt.show()
width = 28000000; lon_0 = 154; lat_0 = -24
m = Basemap(width=width,height=width,projection='aeqd',
lat_0=lat_0,lon_0=lon_0)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
xpt, ypt = m(lon_0, lat_0)
m.plot([xpt],[ypt],'ko')
plt.title("aeqd Azimuthal Equidistant Projection")
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='hammer',lon_0=140,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("hammer Hammer Projection")
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='sinu',lon_0=140,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("sinu Sinusoidal Projection")
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='moll',lon_0=140,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("moll Mollweide Projection")
plt.show()
m = Basemap(width=25.e6,height=25.e6,\
projection='gnom',lat_0=-24.,lon_0=140)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("gnom Gnomonic Projection")
plt.show()
# lon_0 is central longitude of projection.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='mbtfpq',lon_0=140,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("mbtfpq McBryde-Thomas Flat Polar Quartic Projection")
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'i' means use intermediate resolution coastlines.
# lon_0, lat_0 are the central longitude and latitude of the projection.
m = Basemap(llcrnrlon=0,llcrnrlat=-40,urcrnrlon=180,urcrnrlat=10,
resolution='c',projection='cass',lon_0=140,lat_0=-20)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("cass Cassini Projection")
plt.show()
#### setup lambert conformal basemap.
# lat_1 is first standard parallel.
# lat_2 is second standard parallel (defaults to lat_1).
# lon_0,lat_0 is central point.
# rsphere=(6378137.00,6356752.3142) specifies WGS4 ellipsoid
# area_thresh=1000 means don't plot coastline features less
# than 1000 km^2 in area.
m = Basemap(width=36000000,height=9000000,
rsphere=(6378137.00,6356752.3142),\
resolution='c',area_thresh=1000.,projection='lcc',\
lat_1=-10.,lat_2=-40,lat_0=-24,lon_0=150.)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("lcc Lambert Conformal Projection")
plt.show()
# llcrnrlat,llcrnrlon,urcrnrlat,urcrnrlon
# are the lat/lon values of the lower left and upper right corners
# of the map.
# resolution = 'c' means use crude resolution coastlines.
m = Basemap(projection='mill',llcrnrlat=-90,urcrnrlat=90,\
llcrnrlon=-180,urcrnrlon=180,resolution='c')
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("mill Miller Projection")
plt.show()
# setup albers equal area conic basemap
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
# lon_0,lat_0 is central point.
m = Basemap(width=8000000,height=7000000,
resolution='c',projection='aea',\
lat_1=-10.,lat_2=-60,lon_0=140,lat_0=-20)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("aea Albers Equal Area Projection")
plt.show()
# setup albers equal area conic basemap
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
# lon_0,lat_0 is central point.
m = Basemap(width=16000000,height=14000000,
resolution='c',projection='aea',\
lat_1=-10.,lat_2=-60,lon_0=140,lat_0=0)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("aea Albers Equal Area Projection")
plt.show()
# setup albers equal area conic basemap
# lat_1 is first standard parallel.
# lat_2 is second standard parallel.
# lon_0,lat_0 is central point.
m = Basemap(width=16000000,height=14000000,
resolution='c',projection='aea',\
lat_1=-10.,lat_2=-60,lon_0=140,lat_0=0)
m.drawcoastlines()
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,360.,60.))
plt.title("aea Albers Equal Area Projection")
plt.show()