本文整理汇总了Python中mpl_toolkits.basemap.Basemap.fillcontinents方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.fillcontinents方法的具体用法?Python Basemap.fillcontinents怎么用?Python Basemap.fillcontinents使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.fillcontinents方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
class Map:
def __init__(self, boundary=[[24.527135, -127.792969], [49.61071, -59.765625]], default=True):
from mpl_toolkits.basemap import Basemap
minLat, minLon, maxLat, maxLon = [item for t in boundary for item in t]
self.m = Basemap(
llcrnrlon=minLon,
llcrnrlat=minLat,
urcrnrlon=maxLon,
urcrnrlat=maxLat,
resolution="l",
projection="merc",
area_thresh=1000000,
lon_0=minLon + (maxLon - minLon) / 2,
lat_0=minLat + (maxLat - minLat) / 2,
)
if default:
self.configure()
def configure(self):
self.m.drawcoastlines(linewidth=1.0)
self.m.drawcountries(linewidth=1.0)
self.m.fillcontinents(color="#FFFFFF", lake_color="#FFFFFF")
self.m.drawstates(linewidth=0.5)
self.m.drawmapboundary(fill_color="#FFFFFF")
def plotPoints(self, longitude, latitudes, color, lw=0, marker="o", *args, **kwargs):
mlon, mlat = self.m(longitude, latitudes)
self.m.plot(mlon, mlat, color=color, lw=lw, marker=marker, *args, **kwargs)
示例2: mapTut
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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()
示例3: plot_map_twts
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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: individual_ocean_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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: nepal_basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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
示例6: map_interiorAK
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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: get_catalog_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
def get_catalog_map(lats=None, lons=None, eq_cat=[], map_res='i', map_projection='cyl', fignum=0, ax=None, do_clf=True):
#
if lats==None: lats = [31., 42.]
if lons==None: lons = [-125., -114.]
#
if fignum!=None: plt.figure(fignum)
if do_clf: plt.clf()
if ax==None: ax=plt.gca()
#
cm = Basemap(llcrnrlon=lons[0], llcrnrlat=lats[0], urcrnrlon=lons[1], urcrnrlat=lats[1], resolution=map_res, projection=map_projection, lon_0=numpy.mean(lons), lat_0=numpy.mean(lats), ax=ax)
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)
# drawlsmask(land_color='0.8', ocean_color='w', lsmask=None, lsmask_lons=None, lsmask_lats=None, lakes=True, resolution='l', grid=5, **kwargs)
#cm.drawlsmask(land_color='0.8', ocean_color='c', lsmask=None, lsmask_lons=None, lsmask_lats=None, lakes=True, resolution=mapres, grid=5)
print("lat, lon ranges: ", lats, lons)
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])
#
if eq_cat!=None:
# can we also assign sizes dynamically, like colors?
if hasattr(eq_cat, 'dtype'):
# it's a recrray:
X,Y = cm(eq_cat['lon'], eq_cat['lat'])
else:
# it's probably a list... though we should check for dicts, etc.
X,Y = cm([rw[2] for rw in eq_cat], [rw[1] for rw in eq_cat])
#
cm.plot(X,Y, '.')
#
return cm
示例8: background_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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
示例9: example_2
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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')
示例10: ww3_plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
def ww3_plot(fname,xlim=False,ylim=False,res='c'):
'''
ex.:
f='WW3_data/2012/multi_1.glo_30m.dp.201201.grb2'
swanu.ww3_plot(f,xlim=[-100,-80],ylim=[20,32],res='i')
'''
from mpl_toolkits.basemap import Basemap
import pylab as pl
f=pygrib.open(fname)
lat,lon=f.message(1).latlons()
lon[lon>180]=lon[lon>180]-360.
if not xlim: xlim=-180,180
if not ylim: ylim=-90,90
m = Basemap(projection='cyl',llcrnrlat=ylim[0],urcrnrlat=ylim[1],
llcrnrlon=xlim[0],urcrnrlon=xlim[1],resolution=res)
m.drawcoastlines()
m.fillcontinents(color='#cccccc',lake_color='w')
# draw parallels and meridians.
m.drawparallels(np.arange(-90.,91.,30.))
m.drawmeridians(np.arange(-180.,181.,60.))
x,y=m(lon,lat)
pl.plot(x,y,'b.',ms=.5)
pl.show()
示例11: example_1
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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()
示例12: main
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
def main():
data = numpy.genfromtxt("data.csv", dtype=None, delimiter=',', names=True)
#lat - data[x][1]
#lon - data[x][2]
print(data)
# Note that we're drawing on a regular matplotlib figure, so we set the
# figure size just like we would any other.
plt.figure(figsize=(28,18))
# Create the Basemap
event_map = Basemap(projection='merc',
resolution='l', area_thresh=1000.0, # Low resolution
lat_0 = 55.0, lon_0=60.0, # Map center
llcrnrlon=-179, llcrnrlat=-72, # Lower left corner
urcrnrlon=179, urcrnrlat=78) # Upper right corner
# Draw important features
event_map.drawcoastlines()
event_map.drawcountries()
event_map.fillcontinents(color='0.8') # Light gray
event_map.drawmapboundary()
a = [f for f in data if int(f[2])<500]
b = [f for f in data if int(f[2])<500]
# Draw the points on the map:
for i in range(len(data)-8000):
x, y = event_map(data[i][2], data[i][1]) # Convert lat, long to y,x
marker_size = data[i][3]/4
event_map.plot(x,y, 'ro', markersize=marker_size, alpha=0.3)
plt.savefig('map.png', bbox_inches='tight')
示例13: plotPointsOnUSMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
def plotPointsOnUSMap(points, blueMarble=False, bkcolor='#85A6D9', returnBaseMapObject = False, pointLabels=[], *args, **kwargs):
from mpl_toolkits.basemap import Basemap
m = Basemap(llcrnrlon=-125.15625, llcrnrlat=20, urcrnrlon=-59.765625, urcrnrlat=49.61071, projection='mill', lat_1=24, lat_2=50, lon_0=-98, resolution='l', area_thresh=10000)
m.drawmapboundary(fill_color='#85A6D9')
if blueMarble: m.bluemarble()
else:
m.drawmapboundary(fill_color=bkcolor)
m.fillcontinents(color='white',lake_color=bkcolor)
m.drawcoastlines(color='#6D5F47', linewidth=.4)
m.drawcountries(color='#6D5F47', linewidth=.4)
m.drawstates(color='#6D5F47', linewidth=.4)
# m.fillcontinents(color='white',lake_color='#85A6D9')
# m.drawstates(color='#6D5F47', linewidth=.4)
# m.drawcoastlines(color='#6D5F47', linewidth=.4)
# m.drawcountries(color='#6D5F47', linewidth=.4)
# m.drawmeridians(n.arange(-180, 180, 30), color='#bbbbbb')
# m.drawparallels(n.arange(-90, 90, 30), color='#bbbbbb')
lats, lngs = zip(*points)
x,y = m(lngs,lats)
scatterPlot = m.scatter(x, y, zorder = 2, *args, **kwargs)
for population, xpt, ypt in zip(pointLabels, x, y):
label_txt = str(population)
plt.text( xpt, ypt, label_txt, color = 'black', size='small', horizontalalignment='center', verticalalignment='center', zorder = 3)
if not returnBaseMapObject: return scatterPlot
else: return (scatterPlot, m)
示例14: plot_us
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [as 别名]
def plot_us(lats, lons, save_name=None):
fig = plt.figure(figsize=(10, 10))
ax = fig.add_subplot(111)
big_map = Basemap(resolution='h',
lat_0=36, lon_0=-107.5,
llcrnrlat=32, llcrnrlon=-125,
urcrnrlat=43, urcrnrlon=-110)
big_map.drawcoastlines()
big_map.drawstates()
big_map.drawcountries()
big_map.drawmapboundary(fill_color='#7777ff')
big_map.fillcontinents(color='#ddaa66', lake_color='#7777ff', zorder=0)
x, y = big_map(lons, lats)
big_map.plot(x[0], y[0], 'ro', markersize=2)
axins = zoomed_inset_axes(ax, 20, loc=1)
ll_lat, ll_lon = 37.8, -122.78
ur_lat, ur_lon = 38.08, -122.43
axins.set_xlim(ll_lon, ur_lon)
axins.set_ylim(ur_lon, ur_lat)
small_map = Basemap(resolution='h',
llcrnrlat=ll_lat, llcrnrlon=ll_lon,
urcrnrlat=ur_lat, urcrnrlon=ur_lon,
ax=axins)
small_map.drawcoastlines()
small_map.drawmapboundary(fill_color='#7777ff')
small_map.fillcontinents(color='#ddaa66', lake_color='#7777ff', zorder=0)
x, y = small_map(lons, lats)
small_map.plot(x, y, 'ro', markersize=3)
mark_inset(ax, axins, loc1=2, loc2=4, fc="none", ec="0.5")
if save_name:
fig.savefig(save_name)
示例15: basemap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import fillcontinents [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)