本文整理汇总了Python中mpl_toolkits.basemap.Basemap.bluemarble方法的典型用法代码示例。如果您正苦于以下问题:Python Basemap.bluemarble方法的具体用法?Python Basemap.bluemarble怎么用?Python Basemap.bluemarble使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mpl_toolkits.basemap.Basemap
的用法示例。
在下文中一共展示了Basemap.bluemarble方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: plotMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def plotMap(longitude1, latitude1, longitude2, latitude2, tag1, tag2):
'''
Plots tag points on their appropriate latitude and longitude
coordinates on the world map.
'''
map = Basemap(projection='robin', resolution = 'l', area_thresh = 1000.0,
lat_0=0, lon_0=-130)
map.drawcoastlines()
map.drawcountries()
map.bluemarble()
map.drawmapboundary()
map.drawmeridians(np.arange(0, 360, 30))
map.drawparallels(np.arange(-90, 90, 30))
min_marker_size = 10
#This will plot the latitudes and longitues for Tag1
for lon, lat in zip(longitude1, latitude1):
x,y = map(lon, lat)
msize = min_marker_size
marker_string = get_marker_color(1)
map.plot(x, y, marker_string, markersize=msize)
#This will plot latitudes and longitues for Tag2
for lon, lat in zip(longitude2, latitude2):
x,y = map(lon, lat)
msize = min_marker_size
marker_string = get_marker_color(2)
map.plot(x, y, marker_string, markersize=msize)
title_string = "#" + tag1 +"(green) and #" + tag2 + "(red) currently trending\n"
plt.title(title_string)
plt.show()
示例2: plotme
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def plotme(lats,lons,contries,ymds):
# Making the plot fullscreen
fig = plt.figure(figsize=(20,9))
fig.patch.set_facecolor('k')
map = Basemap(projection='ortho', lat_0 = -90 , lon_0 = 0 ,resolution = 'l')
# Make the globe more realistic
map.bluemarble()
#draw the edge of the map projection region (the projection limb)
#map.drawmapboundary()
#map.drawcountries()
#map.drawstates()
# draw lat/lon grid lines every 30 degrees.
#map.drawmeridians(np.arange(0, 360, 30))
#map.drawparallels(np.arange(-90, 90, 30))
#CS = map.nightshade(ymds)
# compute the native map projection coordinates for contries.
x,y = map(lons,lats)
# plot circle.
map.plot(x,y,'rx', ms=10, mew=5)
plt.show()
示例3: drawMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def drawMap(report):
entries = get_site_status(report)
# entries = {'unl.edu': [276, 0, 246, 0], 'desy.de': [107, 0, 0, 0], 'fnal.gov': [16, 0, 294, 0], 'N/A': [0, 0, 0, 0]}
posList = get_positions(entries)
#bounds = [(-60, -120), (60, 120)]
#bounds = [(30, -10), (60, 40)]
bounds = get_bounds(posList, margin = 10)
matplotlib.pyplot.subplots_adjust(left=0, right=1, top=1, bottom=0, wspace=0, hspace=0)
fig = matplotlib.pyplot.figure(figsize=(12, 6))
ax = matplotlib.pyplot.subplot(111)
m = Basemap(projection='cyl', lat_0=0, lon_0=0,
llcrnrlon=bounds[0][0], llcrnrlat=bounds[0][1],
urcrnrlon=bounds[1][0], urcrnrlat=bounds[1][1])
map_positions(m, posList)
#posList = remove_all_overlap(posList)
#print posList
m.bluemarble()
for pos in posList:
draw_pie(ax, pos['info'], (pos['x'], pos['y']), pos['size'])
ax.text(pos['x']+5, pos['y']+5, pos['site'], color='white', fontsize=8)
fig.savefig(os.path.expanduser('~/map.png'), dpi=300)
示例4: __init__
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
class MapDrawer:
mymap = None;
projection = 'hammer';
def __init__(self, projection = 'hammer', lon_0 = 0, resolution = 'c'):
self.mymap = Basemap(projection, lon_0, resolution);
self.mymap.bluemarble()
def show_map(self):
self.mymap.show();
def draw_markers(self, lats, longs, title = '', clever_mode = 0):
# draw parallels and meridians.
lats = np.array(lats)
longs = np.array(longs)
if clever_mode:
print "Clever mode is under construction"
xpt,ypt = self.mymap(longs,lats)
print xpt;
self.mymap.plot(xpt, ypt, 'ro')
if title:
plt.title('Tweets about ' + title)
plt.show()
#mymap = Basemap(projection = 'hammer', lon_0 = 0, resolution = 'c');
#xpt,ypt = mymap(longs,lats)
#mymap.plot(xpt, ypt, 'ro')
示例5: displaymap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def displaymap(region=__AUSREGION__,
subregions=[], labels=[], colors=[], linewidths=[],
fontsize='small', bluemarble=True, drawstates=True):
'''
regions are [lat,lon,lat,lon]
'''
m = Basemap(projection='mill', resolution='f',
llcrnrlon=region[1], llcrnrlat=region[0],
urcrnrlon=region[3], urcrnrlat=region[2])
if bluemarble:
m.bluemarble()
else:
m.drawcountries()
if drawstates:
m.drawstates()
# Add lats/lons to map
add_grid_to_map(m,xy0=(-10,-80),xyres=(10,10),dashes=[1,1e6],labels=[1,0,0,1])
for r in subregions:
if len(labels)<len(r):
labels.append('')
if len(colors)<len(r):
colors.append('k')
if len(linewidths)<len(r):
linewidths.append(1)
# add subregions and little lables:
for r,l,c,lw in zip(subregions, labels, colors, linewidths):
plot_rec(m,r,color=c, linewidth=lw)
lon,lat=r[1],r[2]
x,y = m(lon,lat)
plt.text(x+100,y-130,l,fontsize=fontsize,color=c)
return m
示例6: plotPointsOnUSMap
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [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)
示例7: plot
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def plot(self):
''' plot some random stuff '''
# random data
'''data = [random.random() for i in range(2)]
# create an axis
ax = self.figure.add_subplot(111)
# discards the old graph
ax.hold(False)
# plot data
ax.plot(data, '*-')'''
m = Basemap(projection='robin',lon_0=0,resolution='c')#,latlon=True)
m.bluemarble(scale=0.2)
for friend in rpc.bridge.getFriendList():
print ''
pd = rpc.bridge.getPeerDetails(friend)
print pd['name']
print pd['extAddr']
ld = gi.record_by_addr(pd['extAddr'])
print ld
if ld:
print ld['latitude'],ld['longitude']
x, y = m(ld['longitude'],ld['latitude'])
#m.scatter(x, y,30,marker='o',color='k')
plt.plot(x, y,'ro')
plt.text(x,y,pd['name'],fontsize=9,
ha='center',va='top',color='r',
bbox = dict(boxstyle="square",ec='None',fc=(1,1,1,0.5)))
#plt.text(x,y,pd['name'],fontsize=14,fontweight='bold',
# ha='center',va='center',color='r')
# refresh canvas
self.canvas.draw()
示例8: __init__
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
class Carmap:
'''
making a map with basemap
install basemap: http://gnperdue.github.io/yak-shaving/osx/python/matplotlib/2014/05/01/basemap-toolkit.html
'''
def __init__(self):
self.m = Basemap(llcrnrlon=-93.7, llcrnrlat=28., urcrnrlon=-66.1, urcrnrlat=39.5,
projection='lcc', lat_1=30., lat_2=60., lat_0=34.83158, lon_0=-98.)
def plot(self, lon, lat, color):
'''
making plot at the map
:param color: which color of the dot
'''
lon, lat = lon, lat # Location of Boulder
# convert to map projection coords.
# Note that lon,lat can be scalars, lists or numpy arrays.
xpt, ypt = self.m(lon, lat)
self.m.plot(xpt, ypt, color) # plot a color dot there
def show(self):
self.m.bluemarble() # map style
plt.show()
示例9: generate_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def generate_map(output, latlng, wesn=None):
"""
Using Basemap and the matplotlib toolkit, this function generates a map and
puts a red dot at the location of every IP addresses found in the list.
The map is then saved in the file specified in `output`.
"""
print("Generating map and saving it to {}".format(output))
lats=[]
lngs=[]
for i in latlng:
if i[1]:
lats.append(i[1])
lngs.append(i[2])
if wesn:
wesn = [float(i) for i in wesn.split('/')]
m = Basemap(projection='cyl', resolution='l',
llcrnrlon=wesn[0], llcrnrlat=wesn[2],
urcrnrlon=wesn[1], urcrnrlat=wesn[3])
else:
m = Basemap(projection='cyl', resolution='l')
m.bluemarble()
x, y = m(lngs, lats)
m.scatter(x, y, s=1, color='#ff0000', marker='o', alpha=0.3)
plt.savefig(output, dpi=300, bbox_inches='tight')
示例10: run_main
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def run_main():
""" Main """
tempdir = tempfile.mkdtemp()
print "Downloading shape files from MODIS rapid fire... ",
download(URL_FIRE_SHAPES, "shapes.zip")
zipf = zipfile.ZipFile('shapes.zip')
for name in zipf.namelist():
data = zipf.read(name)
outfile = os.path.join(tempdir, name)
f = open(outfile, 'wb')
f.write(data)
f.close()
zipf.close()
print "done !"
print "Parsing shapefile... ",
shape_path = os.path.join(tempdir, 'Global_%s' % FIRE_LASTS)
r = shapefile.Reader(shape_path)
# print r.fields
print
sr= r.shapeRecords()
print
total=len(sr)
print
xlist=[]
ylist=[]
confidence=[]
for i in xrange(total):
sr_test=sr[i]
xlist.append( sr_test.shape.points[0][0]) #longitude
ylist.append( sr_test.shape.points[0][1]) #latitude
confidence.append( sr_test.record[8])
print "list size: ",len(xlist)
print "done "
print "Rendering... ",
m = Basemap(projection='cyl')
m.bluemarble()
m.scatter(xlist, ylist, 20, c=confidence, cmap=p.cm.YlOrRd, marker='o', edgecolors='none', zorder=10)
p.title("The recent fire hotspots for last %s \n Pixel size: %s | Current Date: %s" % (FIRE_LASTS, RAPIDFIRE_RES,time.strftime("%d/%m/%Y")))
p.show()
print "done !"
os.remove("shapes.zip")
示例11: map_polygons
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def map_polygons(groups):
# Set some hardcoded defaults and map settings
nLAT=89
sLAT=-89
wLON=-179
eLON=179
cLAT=sLAT + (nLAT-sLAT)/2
cLON=wLON + (eLON-wLON)/2
scale_map=0.4
font = {'weight' : 'normal',
'size' : 2}
matplotlib.rc('font', **font)
# Read data into vertices
polygons = dict()
polygons['labels'] = dict(zip(range(len(groups.index)),groups.index))
polygons['LONS'] = dict(zip(range(len(groups.index)),[ [x,y,z,k] for x,y,z,k in zip(groups['xmin'],groups['xmin'],groups['xmax'],groups['xmax'])]))
polygons['LATS'] = dict(zip(range(len(groups.index)),[ [x,y,z,k] for x,y,z,k in zip(groups['ymin'],groups['ymax'],groups['ymax'],groups['ymin'])]))
keys=sorted([x for x in polygons['LATS'].keys()])
# 1. CREATE OBJECTS FOR MAP
fig = plt.figure(figsize=(8, 14), dpi=150)
ax = fig.add_subplot(111)
myMap = Basemap(projection='cyl',
lat_0=cLAT, lon_0=cLON,
llcrnrlat=sLAT,urcrnrlat=nLAT,
llcrnrlon=wLON,urcrnrlon=eLON,
resolution=None)
#myMap.shadedrelief(scale=scale_map)
myMap.bluemarble(scale=scale_map)
#path_effectsTxt=[path_effects.withSimplePatchShadow()]
# 2. NOW ADD POLYGONS
ax.grid(color='k')
for key in keys:
xyList = [[a,b] for a,b in zip(polygons['LONS'][key], polygons['LATS'][key])]#list(zip(polygons['LONS'][key], polygons['LATS'][key]))
p = Polygon(xyList, alpha=0.3,facecolor='yellow',edgecolor=None)
ax.add_artist(p)
plt.text(polygons['LONS'][key][2],polygons['LATS'][key][1],polygons['labels'][key],weight='bold',va='bottom',ha='right',color='yellow') #,path_effects=path_effectsTxt)
path_effectsLine=[path_effects.SimpleLineShadow(),
path_effects.Normal()]
#plt.show()
# 3. SAVE OR RETURN FIG
return fig
#polygons['color']={3:'Blue', \
# 1: 'Cyan', \
# 2: 'Cyan', \
# 6: 'Magenta', \
# 4:'Lime',\
# 5:'Lime',\
# 0:'Gray'}
示例12: generate_image
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def generate_image(year, month, xs=500, ys=500, elev=60, azim=-90, colormap=cm.seismic):
m = Basemap(width=12000000,height=12000000,
rsphere=(6378137.00,6356752.3142),\
resolution='l',area_thresh=1000.,projection='lcc',\
lat_0=45,lon_0=170)
ssl_loc = '/home/guy/Data/cci-ssl/ESACCI-SEALEVEL-L4-MSLA-MERGED-%04d%02d15000000-fv01.nc' % (year, month)
lons_proj, lats_proj, XX, YY, sla = reproject_data(ssl_loc,'sla', m, xsize=xs, ysize=ys, filter=0)
sst_loc = '/mnt/surft/data/SST_CCI_L4_monthly_mean_anomalies/%04d%02d--ESACCI-L4_GHRSST-SSTdepth-OSTIA-GLOB_LT-v02.0-fv01.0_anomalies.nc' %(year, month)
lons_proj, lats_proj, XX, YY, sst = reproject_data(sst_loc,'sst_anomaly', m, xsize=xs, ysize=ys, filter=None)
min_sst = -4
max_sst = 4
colors = np.empty(sst.shape, dtype=np.dtype((float, (4))))
for y in range(sst.shape[1]):
for x in range(sst.shape[0]):
val = sst[x, y]
if(np.ma.getmask(sst[x,y]) == True):
colors[x,y] = (1,0,0,0)
else:
zero_to_one = (val - min_sst) / (max_sst - min_sst)
colors[x, y] = colormap(zero_to_one)
fig = plt.figure(figsize=(19.2,9.6))
ax = plt.subplot(121, projection='3d')
# ax = fig.gca(projection='3d')
ax.view_init(elev=elev, azim=azim)
ax.set_axis_off()
surf = ax.plot_surface(XX, YY, sla, rstride=1, cstride=1, facecolors=colors,#cmap=cm.coolwarm,
linewidth=0, antialiased=False)
ax.set_zlim(-3, 3)
ax.set_xlim((0.22 * xs, 0.78 * xs))
ax.set_ylim((0.18 * ys, 0.82 * ys))
ax2d = plt.subplot(122, aspect=1)
m.bluemarble(ax=ax2d, scale=0.2)
#m.imshow(sst, ax=ax, cmap=cm.coolwarm)
x, y = m(lons_proj, lats_proj)
m.pcolor(x,y, sst, ax=ax2d, cmap=colormap, vmin=min_sst, vmax=max_sst)
#matplotlib.rcParams['contour.negative_linestyle'] = 'dashed'
m.contour(x,y, sla, np.linspace(-1,1,11), colors='k', ax=ax2d)
# m.pcolor(XX, YY, sla, ax=ax)
#ax.pcolormesh(XX,YY,sst, vmin=min_sst, vmax=max_sst, cmap=cm.coolwarm)
# ax = fig.gca()
# surf = ax.pcolormesh(XX,YY,sla, vmin=-limit, vmax=limit)
# fig.colorbar(surf, shrink=0.5, aspect=5)
fig.tight_layout()
return fig
示例13: mapTut
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def mapTut(dLat, dLon):
m = Basemap(width=12000000,height=9000000,projection='lcc',
resolution=None,lat_1=45.,lat_2=55,lat_0=50,lon_0=-107.)
m.bluemarble()
for i in xrange(len(dLat)):
x,y = m(dLon[i],dLat[i])
m.plot(x,y, 'ro')
plt.title("Geo Plotting")
plt.show()
示例14: generate_map
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def generate_map(output, lats=[], lons=[]):
"""
Using Basemap and the matplotlib toolkit, this function generates a map and
puts a red dot at the location of every IP addresses found in the list.
The map is then saved in the file specified in `output`.
"""
print("Generating map and saving it to {}".format(output))
m = Basemap(projection='cyl', resolution='l')
m.bluemarble()
x, y = m(lons, lats)
m.scatter(x, y, s=1, color='#ff0000', marker='o', alpha=0.3)
plt.savefig(output, dpi=300, bbox_inches='tight')
示例15: draw_america
# 需要导入模块: from mpl_toolkits.basemap import Basemap [as 别名]
# 或者: from mpl_toolkits.basemap.Basemap import bluemarble [as 别名]
def draw_america():
plt.figure(figsize=(10, 10), facecolor='w')
m = Basemap(width=7000*1000, height=7000*1000, projection='lcc', resolution='c', lat_0=50, lon_0=-107)
m.drawcoastlines(linewidth=0.3, antialiased=False, color='#303030') # 海岸线
m.drawcountries(linewidth=1, linestyle='-.', antialiased=False, color='k') # 国界
m.drawstates(linewidth=0.5, linestyle='--', antialiased=True, color='k') # 州界
m.drawparallels(np.arange(0, 90, 10), labels=[True, True, False, False]) # 绘制平行线(纬线) [left,right,top,bottom]
m.drawmeridians(np.arange(0, 360, 15), labels=[False, False, False, True], linewidth=1) # 绘制子午线
m.bluemarble() # NASA Blue Marble
plt.tight_layout(4)
plt.title('北美及附近区域遥感图', fontsize=21)
plt.show()