本文整理汇总了Python中mpl_toolkits.basemap.Basemap.drawmapboundary方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.drawmapboundary方法的具体用法?Python Basemap.drawmapboundary怎么用?Python Basemap.drawmapboundary使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.drawmapboundary方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: example_1
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def example_1():
orig_file = '/tmp/comp-tempo/20101206-EUR-L2P_GHRSST-SSTsubskin-AVHRR_METOP_A-eumetsat_sstmgr_metop02_20101206_000403-v01.7-fv01.0.nc'
orig_dset = Dataset(orig_file, 'a')
o_lat = orig_dset.variables['lat'][:].ravel()
o_lon = orig_dset.variables['lon'][:].ravel()
print(np.mean(o_lon))
# 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=133,resolution='l')
m.drawcoastlines()
m.fillcontinents(color='coral',lake_color='aqua')
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,120.,30.))
m.drawmeridians(np.arange(0.,420.,60.))
m.drawmapboundary(fill_color='aqua')
x, y = m(o_lat[0:100] , o_lon[0:100])
#m.plot(x, y)
plt.title("Full Disk Geostationary Projection")
#plt.savefig('geos_full.png')
plt.show()
示例2: plot_map_twts
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def plot_map_twts(twts, title='default title'):
"""
Given an iterable of 'clean' tweets, make a dot map over North America.
"""
fig1 = plt.figure()
ax = fig1.add_subplot(111)
m = Basemap(projection='merc',
resolution = 'l',
llcrnrlon=-136.0, llcrnrlat=24.0,
urcrnrlon=-67.0, urcrnrlat=60.0,
ax=ax)
m.drawcoastlines()
m.drawcountries()
m.drawstates()
m.fillcontinents(color = 'coral', alpha=0.5)
m.drawmapboundary()
lons = [twt['coordinates'][0] for twt in twts]
lats = [twt['coordinates'][1] for twt in twts]
x,y = m(lons, lats)
m.plot(x, y, 'bo', markersize=5)
plt.title(title)
plt.show()
示例3: draw_basic_map_of_toronto
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def draw_basic_map_of_toronto(axis):
"""Draw a basic map of Toronto.
:param axis: where to draw the map
:returns: Basemap with Toronto
"""
# These are the latitudes of the City of Toronto.
# (Fiona can be better to find them, e.g., from the 'icitw_wgs84' Shapefile
# below.)
low_left_corner_longitude = -79.75
low_left_corner_latitude = 43.40
up_right_corner_longitude = -79.10
up_right_corner_latitude = 43.95
to_map = Basemap(
llcrnrlon=low_left_corner_longitude,
llcrnrlat=low_left_corner_latitude,
urcrnrlon=up_right_corner_longitude,
urcrnrlat=up_right_corner_latitude,
ellps="WGS84",
resolution="h",
area_thresh=0.1,
ax=axis,
)
to_map.drawmapboundary(fill_color="white")
return to_map
开发者ID:je-nunez,项目名称:Visualizing_investment_neighborhoods_Toronto,代码行数:30,代码来源:visualiz_investm_toronto_neighborhoods.py
示例4: individual_ocean_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def individual_ocean_map(eof = '1', phase = 'lanina', showplot = True):
### This function combines several others to make a map
patterns, lats, lons, lams, pcs = combine_regions(phase = phase)
data, lns, lts = create_full_map_individual(patterns, lats, lons, eof = eof)
from numpy import linspace
fig = plt.figure()
ax = fig.add_subplot(111)
m = Basemap(ax = ax, projection = 'robin', lon_0 = 180, resolution = 'i')
m.drawmapboundary(fill_color='aqua')
m.drawcoastlines(linewidth = 0.25)
m.drawcountries()
m.fillcontinents(color='green',lake_color='aqua')
parallels = np.linspace(m.llcrnrlat, m.urcrnrlat, 4)
meridians = np.linspace(m.llcrnrlon, m.urcrnrlon, 4)
m.drawparallels(parallels, linewidth = 1, labels = [0,0,0,0])
m.drawmeridians(meridians, linewidth = 1, labels = [0,0,0,0])
cmap = cm.RdBu_r
im = m.pcolormesh(lns,lts,data, vmin = data[~isnan(data)].min(), \
vmax=data[~isnan(data)].max(), cmap = cmap, latlon=True)
cb = m.colorbar(im,'bottom', size="5%", pad="2%")
if showplot:
plt.show()
return
return fig, ax, m
示例5: mapTut
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def mapTut():
m = Basemap(projection='mill',llcrnrlat=20,urcrnrlat=50,\
llcrnrlon=-130,urcrnrlon=-60,resolution='c')
m.drawcoastlines()
m.drawcountries()
m.drawstates()
m.fillcontinents(color='#04BAE3',lake_color='#FFFFFF')
m.drawmapboundary(fill_color='#FFFFFF')
# Houston, Texas
lat,lon = 29.7630556,-95.3630556
x,y = m(lon,lat)
m.plot(x,y, 'ro')
lon, lat = -104.237, 40.125 # Location of Boulder
xpt,ypt = m(lon,lat)
m.plot(xpt,ypt, 'go')
plt.title("Geo Plotting")
plt.show()
示例6: map_interiorAK
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def map_interiorAK(
width=1800000,
height=1200000,
water='lightskyblue',
earth='snow',
resolution='i'):
"""
Albers Equal Area map of interior Alaska, with some overridable presets.
"""
bmap = Basemap(
width=width,
height=height,
resolution=resolution,
projection='aea',
lat_1=55., lat_2=75., lat_0=65., lon_0=-150.)
bmap.drawcoastlines()
bmap.drawrivers(color=water)
bmap.drawcountries()
bmap.fillcontinents(lake_color=water, color=earth)
# labels = [left,right,top,bottom]
bmap.drawmeridians(
np.arange(-180, 180, 10), labels=[False, False, False, 1])
bmap.drawparallels(
np.arange(0, 80, 5), labels=[1, 1, False, False])
bmap.drawmapboundary(fill_color=water)
return bmap
示例7: draw_map_with_labels
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def draw_map_with_labels(labels, map_number):
"""
Draws a map once the labels substituting country names are given
"""
min_lon = -20.
max_lon = 49.
min_lat = 32.
max_lat = 60.
europe = Basemap(
resolution='l',
projection='aea',
lon_0=0,
lat_0=40,
llcrnrlat=min_lat,
urcrnrlat=max_lat,
llcrnrlon=min_lon,
urcrnrlon=max_lon,
lat_ts=(min_lon+max_lon)/2)
europe.drawcountries(linewidth=0.2, color=COUNTRY_COLOR)
europe.drawmapboundary(linewidth=0.5, fill_color=SEA_COLOR)
europe.fillcontinents(color=LAND_COLOR, lake_color=SEA_COLOR)
europe.drawcoastlines(linewidth=0.2)
for label in labels:
lon, lat = europe(label[1], label[2])
plt.text(lon, lat, label[0],
color=TEXT_COLOR, fontweight='heavy', fontstyle='oblique',
ha='center', clip_on=True)
plt.tight_layout()
logging.info('Saving into file: languages_{}.png'.format(map_number + 1))
plt.savefig('languages_{}.png'.format(map_number + 1))
示例8: plot_hmap_ortho
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def plot_hmap_ortho(h, cmap='jet', mode='log', mx=None, drng=None,
res=0.25, verbose=False):
m = Basemap(projection='ortho',lat_0=90,lon_0=180,rsphere=1.)
if verbose:
print 'SCHEME:', h.scheme()
print 'NSIDE:', h.nside()
lons,lats,x,y = m.makegrid(360/res,180/res, returnxy=True)
lons = 360 - lons
lats *= a.img.deg2rad; lons *= a.img.deg2rad
y,x,z = a.coord.radec2eq(n.array([lons.flatten(), lats.flatten()]))
ax,ay,az = a.coord.latlong2xyz(n.array([0,0]))
data = h[x,y,z]
data.shape = lats.shape
data /= h[0,0,1]
#data = data**2 # only if a voltage beam
data = data_mode(data, mode)
m.drawmapboundary()
m.drawmeridians(n.arange(0, 360, 30))
m.drawparallels(n.arange(0, 90, 10))
if mx is None: mx = data.max()
if drng is None:
mn = data.min()
# if min < (max - 10): min = max-10
else: mn = mx - drng
step = (mx - mn) / 10
levels = n.arange(mn-step, mx+step, step)
return m.imshow(data, vmax=mx, vmin=mn, cmap=cmap)
示例9: onpress
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def onpress(event):
if event.button != 1:
return
x, y = event.x, event.y
coord_lat = 40
coord_lon = -75
zoom_map = Basemap(projection='mill',
llcrnrlat=coord_lat,
llcrnrlon=coord_lon,
urcrnrlat=43,
urcrnrlon=-69.5,
resolution='c')
zoom_map.drawcoastlines()
zoom_map.drawcountries()
zoom_map.drawmapboundary()
zoom_map.drawstates()
for i in range(len(size)):
if size[i] <= 5000:
zoom_map.plot(x[i], y[i], 'go', markersize=size[i]/1000)
elif size[i] >= 10000:
zoom_map.plot(x[i], y[i], 'ro', markersize=size[i]/1000)
else:
zoom_map.plot(x[i], y[i], 'bo', markersize=size[i]/1000)
plt.show()
示例10: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def plot(self,key='Re'):
"""
Create a plot of a variable over the ORACLES study area.
Parameters
----------
key : string
See names for available datasets to plot.
clf : boolean
If True, clear off pre-existing figure. If False, plot over pre-existing figure.
Modification history
--------------------
Written: Michael Diamond, 08/16/2016, Seattle, WA
Modified: Michael Diamond, 08/21/2016, Seattle, WA
-Added ORACLES routine flight plan, Walvis Bay (orange), and Ascension Island
Modified: Michael Diamond, 09/02/2016, Swakopmund, Namibia
-Updated flihgt track
"""
plt.clf()
size = 16
font = 'Arial'
m = Basemap(llcrnrlon=self.lon.min(),llcrnrlat=self.lat.min(),urcrnrlon=self.lon.max(),\
urcrnrlat=self.lat.max(),projection='merc',resolution='i')
m.drawparallels(np.arange(-180,180,5),labels=[1,0,0,0],fontsize=size,fontname=font)
m.drawmeridians(np.arange(0,360,5),labels=[1,1,0,1],fontsize=size,fontname=font)
m.drawmapboundary(linewidth=1.5)
m.drawcoastlines()
m.drawcountries()
if key == 'Pbot' or key == 'Ptop' or key == 'Nd' or key == 'DZ':
m.drawmapboundary(fill_color='steelblue')
m.fillcontinents(color='floralwhite',lake_color='steelblue',zorder=0)
else: m.fillcontinents('k',zorder=0)
if key == 'Nd':
m.pcolormesh(self.lon,self.lat,self.ds['%s' % key],cmap=self.colors['%s' % key],\
latlon=True,norm = LogNorm(vmin=self.v['%s' % key][0],vmax=self.v['%s' % key][1]))
elif key == 'Zbf' or key == 'Ztf':
levels = [0,250,500,750,1000,1250,1500,1750,2000,2500,3000,3500,4000,5000,6000,7000,8000,9000,10000]
m.contourf(self.lon,self.lat,self.ds['%s' % key],levels=levels,\
cmap=self.colors['%s' % key],latlon=True,extend='max')
elif key == 'DZ':
levels = [0,500,1000,1500,2000,2500,3000,3500,4000,4500,5000,5500,6000,6500,7000]
m.contourf(self.lon,self.lat,self.ds['%s' % key],levels=levels,\
cmap=self.colors['%s' % key],latlon=True,extend='max')
else:
m.pcolormesh(self.lon,self.lat,self.ds['%s' % key],cmap=self.colors['%s' % key],\
latlon=True,vmin=self.v['%s' % key][0],vmax=self.v['%s' % key][1])
cbar = m.colorbar()
cbar.ax.tick_params(labelsize=size-2)
cbar.set_label('[%s]' % self.units['%s' % key],fontsize=size,fontname=font)
if key == 'Pbot' or key == 'Ptop': cbar.ax.invert_yaxis()
m.scatter(14.5247,-22.9390,s=250,c='orange',marker='D',latlon=True)
m.scatter(-14.3559,-7.9467,s=375,c='c',marker='*',latlon=True)
m.scatter(-5.7089,-15.9650,s=375,c='chartreuse',marker='*',latlon=True)
m.plot([14.5247,13,0],[-22.9390,-23,-10],c='w',linewidth=5,linestyle='dashed',latlon=True)
m.plot([14.5247,13,0],[-22.9390,-23,-10],c='k',linewidth=3,linestyle='dashed',latlon=True)
plt.title('%s from MSG SEVIRI on %s/%s/%s at %s UTC' % \
(self.names['%s' % key],self.month,self.day,self.year,self.time),fontsize=size+4,fontname=font)
plt.show()
示例11: basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def basemap():
#basemap
try:
from mpl_toolkits.basemap import Basemap
import matplotlib.pyplot as plt
#import numpy as np
# use low resolution coastlines.
map = Basemap(boundinglat=22,lon_0=0,projection='npaeqd',resolution='l')
# draw coastlines, country boundaries, fill continents.
map.drawcoastlines(linewidth=0.25)
map.drawcountries(linewidth=0.25)
map.fillcontinents(color='white')
# draw the edge of the map projection region (the projection limb)
map.drawmapboundary()
plt.title('Contours of countries for orthographic basemap')
plt.show()
return 0
except IOError as err:
print "File error: " + str(err)
except ValueError as err:
print "Value Error: " + str(err)
示例12: background_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def background_map(self, ax):
llcrnrlat, urcrnrlat, llcrnrlon, urcrnrlon, lat_ts = (31, 44, -126, -113, 37.5)
m = Basemap(projection='merc', llcrnrlat=llcrnrlat,
urcrnrlat=urcrnrlat, llcrnrlon=llcrnrlon, urcrnrlon=urcrnrlon,
lat_ts=lat_ts, resolution='i', ax=ax)
m.drawmapboundary(fill_color='lightblue', zorder=0)
m.fillcontinents(zorder=0)
etopofn = '/home/behry/uni/data/etopo1_central_europe_gmt.grd'
etopodata = Dataset(etopofn, 'r')
z = etopodata.variables['z'][:]
x_range = etopodata.variables['x_range'][:]
y_range = etopodata.variables['y_range'][:]
spc = etopodata.variables['spacing'][:]
lats = np.arange(y_range[0], y_range[1], spc[1])
lons = np.arange(x_range[0], x_range[1], spc[0])
topoin = z.reshape(lats.size, lons.size, order='C')
# transform to nx x ny regularly spaced 5km native projection grid
nx = int((m.xmax - m.xmin) / 5000.) + 1; ny = int((m.ymax - m.ymin) / 5000.) + 1
topodat, x, y = m.transform_scalar(np.flipud(topoin), lons, lats, nx, ny, returnxy=True)
ls = LightSource(azdeg=300, altdeg=15, hsv_min_sat=0.2, hsv_max_sat=0.3,
hsv_min_val=0.2, hsv_max_val=0.3)
# shade data, creating an rgb array.
rgb = ls.shade(np.ma.masked_less(topodat / 1000.0, 0.0), cm.gist_gray_r)
m.imshow(rgb)
m.drawmeridians(np.arange(6, 12, 2), labels=[0, 0, 0, 1], color='white',
linewidth=0.5, zorder=0)
m.drawparallels(np.arange(44, 50, 2), labels=[1, 0, 0, 0], color='white',
linewidth=0.5, zorder=0)
m.drawcoastlines(zorder=1)
m.drawcountries(linewidth=1.5, zorder=1)
m.drawstates()
m.drawrivers(color='lightblue', zorder=1)
return m
示例13: example_2
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def example_2():
# retrieve data
dir = "/homespace/gaubert/viirs/Mband-SDR"
geo_file = h5py.File("%s/%s" %(dir,"GMODO_npp_d20030125_t0847056_e0848301_b00015_c20090513182937526121_gisf_pop.h5"))
lats = geo_file['All_Data']['VIIRS-MOD-GEO_All']['Latitude'][:]
lons = geo_file['All_Data']['VIIRS-MOD-GEO_All']['Longitude'][:]
# draw map with markers for float locations
#m = Basemap(projection='hammer',lon_0=180)
lon_ref = lons[0][0]-lons[-1][-1]/2
lat_ref = 10
#m = Basemap(projection='ortho',lat_0=lat_ref,lon_0=lon_ref,resolution='l')
m = Basemap(projection='nsper',lat_0=lat_ref,lon_0=lon_ref,satellite_height=2000*1000,resolution='l')
#x, y = m(lons[0:10],lats[0:10])
x,y = m(lons,lats)
#m.drawcoastlines()
m.drawmapboundary(fill_color='#99ffff')
m.fillcontinents(color='#cc9966',lake_color='#99ffff')
m.scatter(x,y,s = 1 ,color='k')
#m.drawgreatcircle(lons[0][0],lats[0][0],lons[0][-1],lats[0][-1],linewidth=2,color='b')
#m.drawgreatcircle(lons[-1][0],lats[0][0],lons[-1][-1],lats[0][-1],linewidth=2,color='b')
plt.title('Locations of %s ARGO floats active between %s and %s' %\
(len(lats),'2002', '2003'))
plt.savefig('/tmp/plotargo.png')
示例14: sstMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def sstMap(nipaPhase, phase = 'allyears', field = 'sst', fig = None, ax = None, monte = False):
from numpy import linspace
if fig == None:
fig = plt.figure()
ax = fig.add_subplot(111)
m = Basemap(ax = ax, projection = 'robin', lon_0 = 270, resolution = 'i')
m.drawmapboundary(fill_color='aqua')
m.drawcoastlines(linewidth = 0.25)
m.drawcountries()
m.fillcontinents(color='green',lake_color='aqua')
parallels = np.linspace(m.llcrnrlat, m.urcrnrlat, 4)
meridians = np.linspace(m.llcrnrlon, m.urcrnrlon, 4)
m.drawparallels(parallels, linewidth = 1, labels = [0,0,0,0])
m.drawmeridians(meridians, linewidth = 1, labels = [0,0,0,0])
lons = nipaPhase.lon[field]
lats = nipaPhase.lat[field]
if monte:
data = nipaPhase.monte_grid[phase]
levels = linspace(0, data.max(), data.max())
cmap = cm.Reds
else:
data = nipaPhase.corr_grid[field][phase]
levels = linspace(-0.8,0.8,9)
cmap = cm.RdBu
lons, lats = np.meshgrid(lons,lats)
im1 = m.pcolormesh(lons,lats,data, vmin = np.min(levels), \
vmax=np.max(levels), cmap = cmap, latlon=True)
cb = m.colorbar(im1,'bottom', size="5%", pad="2%")
ax.set_title('%s, %s' % (phase, field))
return fig, ax, m
示例15: drawNPole
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawmapboundary [as 别名]
def drawNPole(self):
#No es muy ortodoxo dibujar dentro de la clase
my_map = Basemap(projection='npstere',boundinglat=50,lon_0=270,resolution='h', round=True)
my_map.drawcoastlines()
my_map.drawcountries()
my_map.fillcontinents(color='coral')
my_map.drawmapboundary()
#print "tamano:", len(self)
for measure in self:
x,y = my_map(measure.getLon(), measure.getLat())
print measure.getLat(), measure.getLon(), measure.getSic()
color = 'go'
#print "color->", measure.getSic()
if measure.getSic()>0 and measure.getSic()<=0.2:
color = 'go'
elif measure.getSic()>0.2 and measure.getSic()<=0.5:
color = 'yo'
else:
color = 'ro'
my_map.plot(y, x, color, markersize=12)
my_map.drawmeridians(np.arange(0, 360, 30))
my_map.drawparallels(np.arange(-90, 90, 30))
#m.hexbin(x1,y1, C=sic[beam],gridsize=len(sic[beam]),cmap=plt.cm.jet)
plt.gcf().set_size_inches(18,10)
plt.show()