本文整理汇总了Python中mpl_toolkits.basemap.Basemap.drawcountries方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.drawcountries方法的具体用法?Python Basemap.drawcountries怎么用?Python Basemap.drawcountries使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.drawcountries方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: makeMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def makeMap(latList, lonList, cityList):
minLon = -130
minLat = 25
maxLon = -60
maxLat = 50
# Below is used to offset a bit the labels of the cities, for projection='merc'.
labelYOffset = -0.9
labelXOffset = 0.8
# Below is used to offset a bit the labels of the cities, for projection='cyl'.
#labelYOffset = -0.4
#labelXOffset = 0.8
plt.figure(1, figsize=(15, 15))
myMap = Basemap(minLon, minLat, maxLon, maxLat, projection='merc', resolution='h')
myMap.drawcoastlines()
# Below if we want to show counties.
#myMap.drawcounties(linewidth=1, linestyle='solid', color='red')
# Below if we want to show states.
#myMap.drawstates(linewidth=2, linestyle='solid', color='green')
myMap.drawcountries(linewidth=3, linestyle='solid', color='black')
myMap.drawrivers(linewidth=1, linestyle='solid', color='blue')
# Another nice option is shaderelief().
#myMap.shadedrelief()
myMap.etopo()
myMap.scatter(latList, lonList, latlon=True, c='red', s=100)
X, Y = myMap(latList, lonList)
# The for loop is to add the text labels of the cities.
for x, y, label in zip(X, Y, cityList):
plt.text(x + labelXOffset, y + labelYOffset, label)
return plt.show()
示例2: draw_latlon
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def draw_latlon(llclat, urclat, llclon, urclon, rsphere=6371200, resolution='h', area_thresh=0.1, projection='merc'):
m = Basemap(llcrnrlat=llclat, urcrnrlat=urclat,
llcrnrlon=llclon, urcrnrlon=urclon,
rsphere=rsphere, resolution=resolution,
area_thresh=area_thresh, projection=projection)
m.drawcoastlines()
m.drawcountries()
示例3: plot_map_twts
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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()
示例4: contourMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def contourMap(grdROMS, tlon, tlat, mydata1, mydata2, mydata3, var, mytype, currentdate):
plt.figure(figsize=(10,10), frameon=False)
map = Basemap(lon_0=25,boundinglat=50,
resolution='l',area_thresh=100.,projection='npstere')
x, y = list(map(tlon,tlat))
map.drawcoastlines()
map.fillcontinents(color='grey')
map.drawcountries()
if var=='wind':
levels = np.arange(np.min(mydata3),np.max(mydata3),0.1)
CS1 = map.contourf(x, y, mydata3, levels, cmap=cm.get_cmap('RdYlBu_r',len(levels)-1) )#,alpha=0.5)
plt.colorbar(CS1, orientation='vertical', extend='both', shrink=0.5)
if mytype=="REGSCEN":
step=8
else:
step=1
map.quiver(x[0:-1:step,0:-1:step],y[0:-1:step,0:-1:step],
mydata1[0:-1:step,0:-1:step],mydata2[0:-1:step,0:-1:step],
scale=400)
# plt.title('Var:%s - depth:%s - time:%s'%(var,grdROMS.time))
plotfile='figures/'+str(var)+'_'+str(mytype)+'_time_'+str(currentdate)+'.png'
if not os.path.exists('figures'):
os.makedirs('figure')
plt.savefig(plotfile)
print("Saved figure: %s"%(plotfile))
示例5: plot_filtered_diff
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def plot_filtered_diff(self):
"""
function for plotting the difference of filtered vorticity
"""
w_diff, lon, lat, mask = self.vorticity_filter()
south = lat.min(); north =lat.max()
west = lon.min(); east = lon.max()
timeformat = '%Y%m%d-%H%M'
for i in range(len(self.time)):
fig = plt.figure(figsize=(10,8))
basemap = Basemap(projection='merc',llcrnrlat=south,urcrnrlat=north,\
llcrnrlon=west,urcrnrlon=east, resolution='h')
basemap.drawcoastlines()
basemap.fillcontinents(color='coral',lake_color='aqua')
basemap.drawcountries()
basemap.drawstates()
llons, llats=basemap(lon,lat)
con = basemap.pcolormesh(llons,llats,w_diff[i,:,:])
#con.set_clim(vmin=-0.0003, vmax=0.0003)
cbar = plt.colorbar(con, orientation='vertical')
cbar.set_label("vorticity")
#plt.show()
timestr = datetime.strftime(self.time[i], timeformat)
plt.title('vorticity at %s'%timestr)
plt.savefig(self.wdr+'/vorticity_figure/vorticity_diff/'+str(i)+'.png')
print "Saving figure %s to ROMS figure directory"%str(i)
示例6: worldplot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def worldplot(self,kmeans=None,proj='merc'):
"""
plots customer GPS location on a map with state and national boundaries.
IN
kmeans (int) number of means for k-means clustering, default=None
proj (string) the map projection to use, use 'robin' to plot the whole earth, default='merc'
"""
# create a matplotlib Basemap object
if proj == 'robin':
my_map = Basemap(projection=proj,lat_0=0,lon_0=0,resolution='l',area_thresh=1000)
else:
my_map = Basemap(projection=proj,lat_0=33.,lon_0=-125.,resolution='l',area_thresh=1000.,
llcrnrlon=-130.,llcrnrlat=25,urcrnrlon=-65., urcrnrlat=50)
my_map.drawcoastlines(color='grey')
my_map.drawcountries(color='grey')
my_map.drawstates(color='grey')
my_map.drawlsmask(land_color='white',ocean_color='white')
my_map.drawmapboundary() #my_map.fillcontinents(color='black')
x,y = my_map(np.array(self.data['lon']),np.array(self.data['lat']))
my_map.plot(x,y,'ro',markersize=3,alpha=.4,linewidth=0)
if kmeans:
# k-means clustering algorithm---see wikipedia for details
data_in = self.data.drop(['id','clv','level'],axis=1)
# vq is scipy's vector quantization module
output,distortion = vq.kmeans(data_in,kmeans)
x1,y1 = my_map(output[:,1],output[:,0])
my_map.plot(x1,y1,'ko',markersize=20,alpha=.4,linewidth=0)
plt.show()
return output
示例7: plot_world_sst
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def plot_world_sst():
# Read some NetCDF data
import netCDF4 as nc
ostia = nc.Dataset('ostia.nc')
tmp = ostia.variables['analysed_sst'][0]
ice = ostia.variables['sea_ice_fraction'][0]
lon = ostia.variables['lon'][:]
lat = ostia.variables['lat'][:]
from mpl_toolkits.basemap import Basemap
# Set up a map
map = Basemap(projection='cyl')
map.drawcoastlines()
map.drawcountries()
map.fillcontinents(color='lightgreen', lake_color='lightblue');
map.drawmapboundary(fill_color='lightblue')
# Re-project the data onto the map
image = map.transform_scalar(tmp,lon,lat,200,200)
# Plot the data
map.imshow(image);
plt.show()
示例8: draw_map_with_labels
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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))
示例9: drawNPole
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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()
示例10: plot_ICON_clt
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def plot_ICON_clt(ICON_data_dict):
"This function gets ICON data and plots corresponding satellite pictures."
# Import and create basemap for plotting countries and coastlines
from mpl_toolkits.basemap import Basemap
# Create well formatted time_string
time_string = datetime.fromtimestamp(int(unix_time_in)).strftime('%Y-%m-%d-%H-%M')
# Plotting temperature data
plt.figure()
# Plot contourf plot with lat/lon regridded ICON data
cmap_cloud = plt.cm.gray
levels_cloud = np.arange(0,101,10)
plt.contourf(ICON_data_dict["ICON_X_mesh"], ICON_data_dict["ICON_Y_mesh"], ICON_data_dict["ICON_clt"], levels=levels_cloud, cmap=cmap_cloud)
plt.colorbar()
# Plot map data
map = Basemap(llcrnrlon=4.0,llcrnrlat=47.0,urcrnrlon=15.0,urcrnrlat=55.0,
resolution='i')
map.drawcoastlines()
map.drawcountries()
lat_ticks = [55.0,53.0,51.0,49.0,47.0]
map.drawparallels(lat_ticks, labels=[1,0,0,0], linewidth=0.0)
lon_ticks = [4.0,6.0,8.0,10.0,12.0,14.0]
map.drawmeridians(lon_ticks, labels=[0,0,0,1], linewidth=0.0)
# Save plot and show it
plt.savefig(output_path + 'TotalCloudCover_' + time_string + '.png')
示例11: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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()
示例12: onpress
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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()
示例13: Scatter
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def Scatter(data, lons, lats, min, max, cmp, tit, unit, figdir, filename):
# Prepare for drawing
# ny, nx = (50, 116)
# draw Chile Basemap with lambert projection at normal x, y settings
m = Basemap(
llcrnrlon=-78,
llcrnrlat=-56,
urcrnrlon=-66,
urcrnrlat=-17,
projection="cyl",
fix_aspect=False,
lat_1=-43,
lat_2=-30,
lon_0=-72,
) # projection='lcc'
# draw boundaries
m.drawcoastlines()
m.drawcountries(linewidth=2)
m.drawstates()
m.drawparallels(arange(-60, -15, 15), labels=[1, 0, 0, 0]) # only left ytick
m.drawmeridians(arange(-80, -60, 5), labels=[0, 0, 0, 1]) # only bottom xtick
# map data with lon and lat position
im = m.scatter(lons, lats, 30, marker="o", c=data, vmin=min, vmax=max, latlon=True, cmap=cmp)
cb = m.colorbar(im, pad="10%")
plt.title(tit, fontsize=20)
plt.xlabel(unit, labelpad=50)
# savefig('%s%s' % (figdir, filename))
plt.show()
示例14: basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [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)
示例15: nepal_basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import drawcountries [as 别名]
def nepal_basemap(prams = nepal_ETAS_prams, fnum=0, map_res='i', **kwargs):
# hours_after: upper time limit for aftershocks to plot.
prams.update(kwargs)
#
lons_nepal = [83., 87.]
lats_nepal = [26., 30.]
todt=prams.get('todt', None)
catlen=prams.get('catlen', 5.*365.)
lons=prams['lons']
lats=prams['lats']
mc = prams['mc']
#
if todt==None: todt = dtm.datetime.now(pytz.timezone('UTC'))
dt0 = todt - dtm.timedelta(days=catlen)
#
plt.figure(fnum)
plt.clf()
ax1=plt.gca()
cntr = [.5*(lons[0]+lons[1]), .5*(lats[0]+lats[1])]
#
cm=Basemap(llcrnrlon=lons_nepal[0], llcrnrlat=lats_nepal[0], urcrnrlon=lons_nepal[1], urcrnrlat=lats_nepal[1], resolution=map_res, projection='cyl', lon_0=cntr[0], lat_0=cntr[1])
cm.drawcoastlines(color='gray', zorder=1)
cm.drawcountries(color='gray', zorder=1)
cm.drawstates(color='gray', zorder=1)
cm.drawrivers(color='gray', zorder=1)
cm.fillcontinents(color='beige', zorder=0)
#
cm.drawmeridians(list(range(int(lons[0]), int(lons[1]))), color='k', labels=[0,0,1,1])
cm.drawparallels(list(range(int(lats[0]), int(lats[1]))), color='k', labels=[1, 1, 0, 0])
#
return cm