def plot(lon, lat, h): m = Basemap(projection='gall', llcrnrlon=-94.5, llcrnrlat=28.5, urcrnrlon=-88.5, urcrnrlat=34, resolution='f', area_thresh=50.0, lat_0=31.30, lon_0=-92.60 ) fig = plt.figure() fig.suptitle('Local of Type host '+h, fontsize=10) m.drawcoastlines() m.drawcountries() m.drawstates() m.drawrivers(linewidth=0.5, linestyle='solid', color='steelblue', antialiased=1, ax=None, zorder=None) parallels = np.arange(0., 90, 0.5) m.drawparallels(parallels, labels=[False, True, True, False]) meridians = np.arange(10., 351., 1) m.drawmeridians(meridians, labels=[True, False, False, True]) m.fillcontinents(color='gainsboro') m.drawmapboundary(fill_color='steelblue') xpt, ypt = m(lon, lat) lonpt, latpt = m(xpt, ypt, inverse=True) m.plot(xpt, ypt, 'bo') plt.show()
def generate_overviewbase( width=2000000, height=1800000, resolution='l', projection='aea', lat_1=60., lat_2=70., lat_0=65, lon_0=-150, rivercolor=water, continentcolor=earth, lakecolor=water, oceancolor=water, meridianrange=np.arange(-180, 180, 5), meridianlabels=[False, False, False, 1], parallelrange=np.arange(0, 80, 2), parallellabels=[1, 1, False, False] ): mm = Basemap( width=width, height=height, resolution=resolution, projection='aea', lat_1=lat_1, lat_2=lat_2, lat_0=lat_0, lon_0=lon_0) mm.drawcoastlines() mm.drawrivers(color=rivercolor, linewidth=1.5) mm.drawmeridians(meridianrange, labels=meridianlabels) mm.drawparallels(parallelrange, labels=parallellabels) mm.fillcontinents( color=continentcolor, lake_color=lakecolor) mm.drawmapboundary(fill_color=oceancolor) return mm
def generate_willowbase(zoom_in=False, resolution='i'): if zoom_in: width, height = 50000, 40000 lat_0 = 61.8 lon_0 = -150.1 else: width, height = 100000, 80000 lat_0 = 61.8 lon_0 = -149.75 mm = Basemap(width=width, height=height, resolution=resolution, projection='aea', lat_1=55., lat_2=65., lat_0=lat_0, lon_0=lon_0) mm.drawcoastlines() mm.drawrivers(color=water, linewidth=3, zorder=5) mm.drawmeridians(np.arange(-180, 180, 0.25), labels=[False, False, False, 1]) mm.drawparallels(np.arange(0, 80, 0.25), labels=[True, True, False, False]) mm.fillcontinents(color=earth, lake_color=water) mm.drawmapboundary(fill_color=water) mm.readshapefile(primaryroads, 'roads', color="darkslategrey", linewidth=3) return mm
def mapshow(lon, lat, z): from mpl_toolkits.basemap import Basemap if lat.ndim == 1: d0, d1 = numpy.meshgrid( numpy.linspace(lat.min(), lat.max(), lon.shape[1]), numpy.linspace(lon.min(), lon.max(), lon.shape[0])) z = interpolate.griddata((lon.ravel(), lat.ravel()), z.ravel(), (d1, d0), method='linear') else: d0 = lon d1 = lat if lat[0, 0] > 0: #northern hemisphere if d1[0, 0] < d1[-1, 0]: d1 = numpy.flipud(d1) print('Please wait... Generating map\n') m = Basemap(llcrnrlon=d0.min(), llcrnrlat=d1.min(), urcrnrlon=d0.max(), urcrnrlat=d1.max(), resolution='f', area_thresh=1., projection='cyl') m.imshow(z, interpolation='nearest', origin='upper') m.drawcoastlines(color='w', linewidth=0.8) m.drawmapboundary() # draw a line around the map region m.drawrivers() m.drawparallels(numpy.arange(int(d1.min()), int(d1.max()), 1), linewidth=0.2, labels=[1, 0, 0, 0]) m.drawmeridians(numpy.arange(int(d0.min()), int(d0.max()), 1), linewidth=0.2, labels=[0, 0, 0, 1])
def test_plot_map_vels(xml): track = GPX(xml) vels = track.calculate_vels(smooth_vels=True) lllat, lllon = min(track.lat) - 0.01, min(track.lon) - 0.01 urlat, urlon = max(track.lat) + 0.01, max(track.lon) + 0.01 # find the centre point lat_0 = (urlat - lllat) / 2 + lllat lon_0 = (urlon - lllon) / 2 + lllon # FIXME: rsphere required because my Proj is screwy m = Basemap(projection='cyl', llcrnrlon=lllon, llcrnrlat=lllat, urcrnrlon=urlon, urcrnrlat=urlat, lat_0=lat_0, lon_0=lon_0, resolution='h') # rsphere=(6378137.00, 6356752.3142)) x, y = m(vels.lon, vels.lat) m.drawcoastlines() m.drawrivers() m.barbs(x, y, vels.u, vels.v) #, vels.anom, cmap=plt.get_cmap('RdBu_r')) plt.show()
def plot_locations(result,amenity,top): import pandas as pd import numpy lat = [] lon = [] for res in result: lat.append(res['pos'][0]) lon.append(res['pos'][1]) geo = pd.DataFrame(lat, columns = ['lat']) geo['lon'] = lon from mpl_toolkits.basemap import Basemap import matplotlib.pyplot as plt my_map = Basemap(projection='merc', lat_0=geo.median()[0], lon_0=geo.median()[1], resolution = 'h', area_thresh = .1, llcrnrlon=geo.min()[1]-.1, llcrnrlat=geo.min()[0]-.1, urcrnrlon=geo.max()[1]+.1, urcrnrlat=geo.max()[0]+.1) my_map.drawrivers() my_map.drawcounties() my_map.fillcontinents(color='tan') my_map.drawmapboundary() my_map.drawcoastlines() x,y = my_map(lon, lat) my_map.plot(x,y, 'bo', markersize=2) title = 'Map Showing %s Added by \"%s\"\nThe Top %s Editor' % (str(amenity).title(),str(top),str(amenity).title()) plt.title(title) p = plt.show() return p
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
def generate_overviewbase( width=2000000, height=1800000, resolution='l', projection='aea', lat_1=60., lat_2=70., lat_0=65, lon_0=-150, rivercolor=water, continentcolor=earth, lakecolor=water, oceancolor=water, meridianrange=np.arange(-180, 180, 5), meridianlabels=[False, False, False, 1], parallelrange=np.arange(0, 80, 2), parallellabels=[1, 1, False, False] ): mm = Basemap( width=width, height=height, resolution=resolution, projection='aea', lat_1=lat_1, lat_2=lat_2, lat_0=lat_0, lon_0=lon_0) mm.drawcoastlines() mm.drawrivers(color=rivercolor, linewidth=1.5) mm.drawmeridians(meridianrange, labels=meridianlabels) mm.drawparallels(parallelrange, labels=parallellabels) mm.fillcontinents( color=continentcolor, lake_color=lakecolor) mm.drawmapboundary(fill_color=oceancolor) # mm.readshapefile( # "/Volumes/SCIENCE/GIS_Data/catalog.data.gov/tl_2013_02_prisecroads/tl_2013_02_prisecroads", # 'roads', # color="slategrey", linewidth=2) return mm
def roc_plot(long, lat, data): # Setup inputs m = long.shape[0]*long.shape[1] long = long.reshape(m) lat = lat.reshape(m) data = data.reshape(m) # Load in locations places = pd.read_csv("../../data/ROC_places.csv",\ names=["Name", "Lat", "Long"]) m = Basemap(projection='lcc', resolution='h',\ lat_0=np.mean(lat), lon_0=np.mean(long),\ width=3e4, height=3e4) m.drawcoastlines(color="black") m.drawrivers(color="black") m.drawparallels(np.linspace(lat[0], lat[-1], 5), labels=[1,0,0,0]) meridians = m.drawmeridians(np.linspace(long[-1], long[0], 5), labels=[0,0,0,1]) for merid in meridians: meridians[merid][1][0].set_rotation(45) m.scatter(long, lat, latlon=True,\ c=data, cmap='Blues') plt.colorbar(label="Probability") plt.clim(0,1) # Plot known places m.scatter(places["Long"].values, places["Lat"].values,\ latlon=True, color="black") for name, n_lat, n_long in places.values: plt.annotate(name, xy=m(n_long, n_lat), xytext=m(n_long, n_lat+0.003)) plt.show()
def plotwithrivers(lat, lon, lat2 = None, lon2 = None): #Plots equal length arrays lat and lon of latitudes and longitudes. WITH RIVERS latLL = min(lat) lonLL = min(lon) latUR = max(lat) lonUR = max(lon) meanlat = np.mean(lat) meanlon = np.mean(lon) map = Basemap(projection='merc' ,llcrnrlon= lonLL - 1,llcrnrlat=latLL -1 , urcrnrlon= lonUR+1,urcrnrlat= latUR+1,resolution='h') #map = Basemap(projection='spstere', boundinglat = latUR +1, lon_0 = meanlon) # draw coastlines, country boundaries, fill continents. map.drawcoastlines(linewidth=0.5) map.drawcountries(linewidth=0.5) # map.fillcontinents(color='coral',lake_color='aqua') # draw the edge of the map projection region (the projection limb) #map.drawmapboundary(fill_color='aqua') # draw lat/lon grid lines every 30 degrees. map.drawmeridians(np.arange(0,360,1)) map.drawparallels(np.arange(-90,90,1)) #map.bluemarble() #NASA image - kek map.drawrivers(linewidth=0.5) map.scatter(lon,lat, latlon = True) try: map.scatter(lon2,lat2,latlon = True , color = 'g') except: print("")
def basemap_standard(lat,lon,*parallels_interval): ## plot the coastline #set up the map in a Equidistant Cylindrical projection #Note: See "oceanographic_python.doc" on how to download and install the 3rd party "Basemap" package from mpl_toolkits.basemap import Basemap m = Basemap(projection='cyl',llcrnrlat=min(lat)-0.01,urcrnrlat=max(lat)+0.01,\ llcrnrlon=min(lon)-0.01,urcrnrlon=max(lon)+0.01,resolution='h')#,fix_aspect=False) # draw coastlines m.drawcoastlines() m.fillcontinents(color='grey') m.drawmapboundary() #draw major rivers m.drawrivers() if len(parallels_interval)<1: parallels_interval=1 #draw parallels m.drawparallels(np.arange(int(min(lat)),int(max(lat))+1,float(parallels_interval)),linewidth=0,labels=[1,0,0,0],fmt=lat2str,dashes=[2,2]) #draw meridians m.drawmeridians(np.arange(int(min(lon)),int(max(lon))+1,float(parallels_interval)),linewidth=0,labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) else: parallels_interval=parallels_interval[0] #draw parallels m.drawparallels(np.arange(round(min(lat)-0.2,3),round(max(lat)+0.2,3),parallels_interval),labels=[1,0,0,0],fmt=lat2str,dashes=[2,2]) #draw meridians m.drawmeridians(np.arange(round(min(lon)-0.2,3),round(max(lon)+0.2,3),parallels_interval),labels=[0,0,0,1],fmt=lon2str,dashes=[2,2])
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
def generate_willowbase(zoom_in=False, resolution='i'): if zoom_in: width, height = 50000, 40000 lat_0 = 61.8 lon_0 = -150.1 else: width, height = 100000, 80000 lat_0 = 61.8 lon_0 = -149.75 mm = Basemap( width=width, height=height, resolution=resolution, projection='aea', lat_1=55., lat_2=65., lat_0=lat_0, lon_0=lon_0) mm.drawcoastlines() mm.drawrivers(color=water, linewidth=3, zorder=5) mm.drawmeridians(np.arange(-180, 180, 0.25), labels=[False, False, False, 1]) mm.drawparallels(np.arange(0, 80, 0.25), labels=[True, True, False, False]) mm.fillcontinents( color=earth, lake_color=water) mm.drawmapboundary(fill_color=water) mm.readshapefile( primaryroads, 'roads', color="darkslategrey", linewidth=3) return mm
def basemap_standard(lat,lon,parallels_interval): ## plot the coastline #set up the map in a Equidistant Cylindrical projection #Note: See "oceanographic_python.doc" on how to download and install the 3rd party "Basemap" package from mpl_toolkits.basemap import Basemap #m = Basemap(projection='cyl',llcrnrlat=min(lat)-0.01,urcrnrlat=max(lat)+0.01,\ # llcrnrlon=min(lon)-0.01,urcrnrlon=max(lon)+0.01,resolution='h')#,fix_aspect=False) m = Basemap(projection='cyl',llcrnrlat=min(lat),urcrnrlat=max(lat),\ llcrnrlon=min(lon),urcrnrlon=max(lon),resolution='h')#,fix_aspect=False) # draw coastlines m.drawcoastlines() m.fillcontinents(color='grey') m.drawmapboundary() #draw major rivers m.drawrivers() #print 'new3\n' #print str(parallels_interval) if parallels_interval[0]<6.0: parallels_interval=parallels_interval[0] #draw parallels #m.drawparallels(np.arange(int(min(lat)),int(max(lat))+1,float(parallels_interval)),linewidth=0,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) #draw meridians #m.drawmeridians(np.arange(int(min(lon)),int(max(lon))+1,float(parallels_interval)),linewidth=0,labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) m.drawparallels(np.arange(min(lat),max(lat)+1,float(parallels_interval)),linewidth=1,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) #draw meridians m.drawmeridians(np.arange(min(lon),max(lon)+1,float(parallels_interval)),linewidth=1,labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) else: parallels_interval=parallels_interval[0] m.drawparallels(np.arange(min(lat),max(lat)+1,float(parallels_interval)),linewidth=1,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) m.drawmeridians(np.arange(min(lon),max(lon)+1,float(parallels_interval)),linewidth=1,labels=[0,0,0,1],fmt=lon2str,dashes=[1,1]) print 'this is '+str(parallels_interval)
def basemap_standard(lat,lon,parallels_interval): # parallels_interval is the # of degrees between longitude labels ## plot the coastline #set up the map in a Equidistant Cylindrical projection #Note: See "oceanographic_python.doc" on how to download and install the 3rd party "Basemap" package #m = Basemap(projection='cyl',llcrnrlat=min(lat)-0.01,urcrnrlat=max(lat)+0.01,\ # llcrnrlon=min(lon)-0.01,urcrnrlon=max(lon)+0.01,resolution='h')#,fix_aspect=False) m = Basemap(projection='cyl',llcrnrlat=min(lat),urcrnrlat=max(lat),\ llcrnrlon=min(lon),urcrnrlon=max(lon),resolution='h')#,fix_aspect=False) # draw coastlines m.drawcoastlines() m.fillcontinents(color='grey') m.drawmapboundary() #draw major rivers m.drawrivers() #print 'new3\n' #print str(parallels_interval) if parallels_interval[0]<6.0: parallels_interval=parallels_interval[0] #draw parallels #m.drawparallels(np.arange(int(min(lat)),int(max(lat))+1,float(parallels_interval)),linewidth=0,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) #draw meridians #m.drawmeridians(np.arange(int(min(lon)),int(max(lon))+1,float(parallels_interval)),linewidth=0,labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) m.drawparallels(np.arange(min(lat),max(lat)+1,float(parallels_interval)),linewidth=1,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) #draw meridians m.drawmeridians(np.arange(min(lon),max(lon)+1,float(parallels_interval)),linewidth=1,labels=[0,0,0,1],fmt=lon2str,dashes=[2,2]) else: parallels_interval=parallels_interval[0] m.drawparallels(np.arange(min(lat),max(lat)+1,float(parallels_interval)),linewidth=1,labels=[1,0,0,0],fmt=lat2str,dashes=[1,1]) m.drawmeridians(np.arange(min(lon),max(lon)+1,float(parallels_interval)),linewidth=1,labels=[0,0,0,1],fmt=lon2str,dashes=[1,1]) print 'this is '+str(parallels_interval)
def DispGeoLocs(): """Display locations in map coordinates :returns: figure handle :rtype: :py:class:`matplotlib.figure.Figure` """ from mpl_toolkits.basemap import Basemap from matplotlib import pyplot as plt places2 = PLACES.copy() places2.pop('Sandheads') places2.pop('Departure Bay') width = 300000 lon_0 = -124.3 lat_0 = 49 fig = plt.figure(figsize=(20, 20)) m = Basemap(width=width, height=width, projection='aeqd', resolution='h', lat_0=lat_0, lon_0=lon_0) m.drawmapboundary() m.drawcoastlines(linewidth=0.5) m.drawrivers() m.drawparallels(range(40, 60, 2)) m.drawmeridians(range(-130, -110, 2)) #plt.title('EC River Stations') # map stations: for pl in places2.keys(): if 'lon lat' in places2[pl].keys(): lon, lat = places2[pl]['lon lat'] if (47 < lat < 51) & (-128 < lon < -120): if pl in ('Sandy Cove', 'Calamity Point', 'Port Moody', 'Vancouver', 'New Westminster', 'Delta DDL node', 'East node', 'Boundary Bay', 'Duke Pt.'): xpt, ypt = m(lon, lat) xpt2, ypt2 = m(lon + .03, lat) m.plot(xpt, ypt, 'ro') plt.text(xpt2, ypt2, pl, fontsize=10, fontweight='bold', ha='left', va='center', color='r') else: xpt, ypt = m(lon, lat) xpt2, ypt2 = m(lon - .03, lat) m.plot(xpt, ypt, 'ro') plt.text(xpt2, ypt2, pl, fontsize=10, fontweight='bold', ha='right', va='center', color='r') return fig
def setup_Basemap(xmin, xmax, ymin, ymax, projection='cyl', resolution='c', \ drawcoastlines=True, drawrivers=True,drawcountries=True, \ meridiantickdist=0, paralleltickdist=0): m = Basemap(projection='cyl', llcrnrlon=xmin, \ urcrnrlon=xmax, llcrnrlat=ymin, urcrnrlat=ymax, resolution=resolution) #xi,yi = m(*np.meshgrid(x, y)) if drawcoastlines: m.drawcoastlines(linewidth=0.25) if drawrivers: m.drawrivers(color='b', linewidth=0.25) if drawcountries: m.drawcountries(linewidth=0.25) m.drawmapboundary(linewidth=0.5) if meridiantickdist > 0: m.drawmeridians(np.arange(xmin, xmax + 1, meridiantickdist), labels=[1, 0, 0, 1], linewidth=0.5, fontsize=10) if paralleltickdist > 0: m.drawparallels(np.arange(ymin, ymax + 1, paralleltickdist), labels=[1, 0, 0, 1], linewidth=0.5, fontsize=10) return m
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
def plotData(dfMcr): fig, ax = plt.subplots(figsize=(10, 10)) m = Basemap( llcrnrlon=lonMcr - 2, llcrnrlat=latMcr - 3, urcrnrlon=lonMcr + 2, urcrnrlat=latMcr + 3, #width=1e5,height=1e5, resolution= 'i', # Set using letters, e.g. c is a crude drawing, f is a full detailed drawing projection= 'tmerc', # The projection style is what gives us a 2D view of the world for this lon_0=lonMcr, lat_0=latMcr, # Setting the central point of the image epsg=27700) # Setting the coordinate system we're using m.drawmapboundary( fill_color='#46bcec') # Make your map into any style you like m.fillcontinents( color='#f2f2f2', lake_color='#46bcec') # Make your map into any style you like m.drawcoastlines() m.drawrivers() # Default colour is black but it can be customised m.drawcountries() x, y = m(lonMcr, latMcr) plt.plot(x, y, 'ok', markersize=10) plt.text(x, y, ' Manchester', fontsize=20) for _, elem in dfMcr.iterrows(): x, y = m(elem.longitude, elem.latitude) m.plot(x, y, marker='o', c='r', markersize=15, alpha=1, latlon=False) plt.show()
def draw_map(lon_column, lat_column, subplot=1, cmap='Blues'): plt.subplot(2, 1, subplot) m = Basemap(projection='merc', resolution='h', urcrnrlon=-8.5363740000000004, urcrnrlat=41.237622000000002, llcrnrlon=-8.6920289999999998, llcrnrlat=41.112071999999998) m.readshapefile('./data/roads', 'landmarks') m.drawcoastlines() m.drawrivers() m.drawcountries() m.drawmapboundary() lon_bins = np.linspace(lon_column.min() - 1, lon_column.max() + 1, 500) lat_bins = np.linspace(lat_column.min() - 1, lat_column.max() + 1, 500) density, _, _ = np.histogram2d(lat_column, lon_column, [lat_bins, lon_bins]) lon_bins_2d, lat_bins_2d = np.meshgrid(lon_bins, lat_bins) xs, ys = m(lon_bins_2d, lat_bins_2d) plt.pcolormesh(xs, ys, density, cmap=plt.get_cmap(cmap)) plt.colorbar(orientation='horizontal') m.scatter(lon_column.tolist(), lat_column.tolist(), alpha=0.00125, latlon=True, c='green') m.drawmapscale(-8.685, 41.14, -8.685, 41.14, 1)
def draw_eastasia(): size = 6500 * 1000 # 6500km plt.figure(figsize=(10, 10), facecolor='w') m = Basemap(width=size, height=size, projection='lcc', resolution='c', lat_0=35.5, lon_0=103.3) m.drawcoastlines(linewidth=0.3, antialiased=False, color='#202020') # 海岸线 m.drawrivers(linewidth=0.05, linestyle='-', color=(0.1, 0.1, 0.1), antialiased=False) # 河流 m.drawcountries(linewidth=1, linestyle='-', antialiased=False) # 国界 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, dashes=[2, 2]) # 绘制子午线 # m.etopo() # 地形高程 m.bluemarble() plt.tight_layout(4) plt.title(u'东亚及附近区域遥感图', fontsize=21) # 东亚及附近区域地理地形图 plt.show()
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
def draw_map(line_res, grid_res): # load topography nco = Dataset(inp_const_path, 'r') hsurf = nco['HSURF'][:] lon = nco['lon_1'][:] lat = nco['lat_1'][:] fig = plt.figure(figsize=(15, 9)) m = Basemap(projection='lcc', resolution=line_res, lon_0=8.5, width=0.65E6, lat_0=47.1, height=0.4E6) m.pcolormesh(lon, lat, hsurf, latlon=True, cmap='terrain', vmin=-1000, vmax=4200, zorder=-1) m.drawcountries(linewidth=1.0) m.drawcoastlines(linewidth=1.0, color='0.2') m.drawlsmask(land_color=(1, 1, 1, 0.), ocean_color=(0, 0.3, 1, 0.5), zorder=1, resolution=line_res, grid=grid_res) m.drawrivers(linewidth=1.0, color=(0, 0.3, 1, 0.2)) return (m)
def draw_bb_map(self, fig, ax, BB=None, range_rings=None, lat_spacing=None, lon_spacing=None): """Draw the Beam Blockage""" if BB is None: BB = self.CBB if lat_spacing is None: lat_spacing = 1.0 if lon_spacing is None: lon_spacing = 1.0 bm2 = Basemap( projection="cea", resolution="l", area_thresh=10000.0, llcrnrlon=self.minlon, urcrnrlon=self.maxlon, llcrnrlat=self.minlat, urcrnrlat=self.maxlat, ax=ax, ) ax.set_title("Beam-blockage fraction", fontdict=TITLEDICT) bm2.drawmeridians(np.arange(self.minlon, self.maxlon, lon_spacing), labels=[1, 0, 0, 1]) bm2.drawparallels(np.arange(self.minlat, self.maxlat, lat_spacing), labels=[1, 0, 0, 1]) bm2.drawcountries() bm2.drawcoastlines() bm2.drawrivers() xbm2, ybm2 = bm2(self.rng_lon, self.rng_lat) BBmap = bm2.pcolormesh(xbm2, ybm2, BB, vmin=0.0, vmax=1.0, cmap=self.bb_cmap) if range_rings is not None: for nn in range(len(range_rings)): self.plot_range_ring(range_rings[nn], bm=bm2) fig.colorbar(BBmap, ax=ax)
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
def create_map(latitudeArray, longitudeArray): LOW_LEFT_CORNR_LONGITUDE = -74.260380 LOW_LEFT_CORNER_LATITUDE = 40.485808 UP_RIGHT_CORNER_LONGITUDE = -73.699206 UP_RIGHT_CORNER_LATITUDE = 40.917691 MIN_NYC_ISLAND_TO_VISUALIZ = 0.6 # Create the Basemap m = Basemap(llcrnrlon=LOW_LEFT_CORNR_LONGITUDE, llcrnrlat=LOW_LEFT_CORNER_LATITUDE, urcrnrlon=UP_RIGHT_CORNER_LONGITUDE, urcrnrlat=UP_RIGHT_CORNER_LATITUDE, ellps='WGS84', resolution='h', area_thresh=MIN_NYC_ISLAND_TO_VISUALIZ) m.drawcoastlines() m.fillcontinents(color="#ebebeb") m.drawcountries(linewidth=3) m.drawstates() m.drawrivers() m.drawmapboundary(fill_color='#ffffff') m.readshapefile('zipshape/cb_2016_us_zcta510_500k', 'zip') plt.scatter(longitudeArray, latitudeArray, marker='.', s=2, color="#006767", zorder=10) plt.show()
def plot_species_occurrence(self, figsize=(16,12), projection='merc'): data_clean = self.data_full.dropna(how='any', subset=['decimalLatitude', 'decimalLongitude']) # latitude/longitude lists data_full_latitude = data_clean.decimalLatitude data_full_longitude = data_clean.decimalLongitude plt.figure(figsize=figsize) plt.title("%s occurrence records from %s " % (self.name_species, self.source.name) ) my_map = Basemap(projection=projection, lat_0=50, lon_0=-100, resolution='l', area_thresh=1000.0, llcrnrlon=data_full_longitude.min(),# lower left corner longitude point llcrnrlat=data_full_latitude.min(), # lower left corner latitude point urcrnrlon=data_full_longitude.max(), # upper right longitude point urcrnrlat=data_full_latitude.max() # upper right latitude point ) # prepare longitude/latitude list for basemap df_x, df_y = my_map(data_full_longitude.tolist(), data_full_latitude.tolist()) my_map.drawcoastlines() my_map.drawcountries() my_map.drawrivers(color='lightskyblue', linewidth=1.5) my_map.drawmapboundary(fill_color='lightskyblue') my_map.fillcontinents(color='cornsilk') # draw latitude and longitude my_map.drawmeridians(np.arange(0, 360, 30)) my_map.drawparallels(np.arange(-90, 90, 30)) my_map.plot(df_x, df_y, 'bo', markersize=5, color="#b01a1a")
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()
def plotMap(llcrnrlon, llcrnrlat, urcrnrlon, urcrnrlat, lons, lats, color, title): m = Basemap(projection='merc', resolution='i', llcrnrlon = llcrnrlon, llcrnrlat = llcrnrlat, urcrnrlon = urcrnrlon, urcrnrlat = urcrnrlat) m.drawcountries(linewidth=1) m.drawcoastlines(linewidth=1) m.drawlsmask() m.drawstates() m.drawrivers(linewidth=.1) plt.title((str(len(lats)))+ \ title, fontsize=12) x,y = m(lons, lats) if color == 'r': plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Reds) if color == 'b': plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Blues) if color == 'g': plt.hexbin(x, y, gridsize=40, cmap=plt.cm.Greens) m.scatter(lons, lats, 1, marker='o',color=color, latlon=True) plt.show()
def _basemap_city(): """ This function creates a Basemap instance that is a map of Chicago with its districts :return city_map """ city_map = Basemap(llcrnrlon=-87.946463888372286, llcrnrlat=41.62846088888256, urcrnrlon=-87.415897644283177, urcrnrlat=42.042643093713917, projection="merc", resolution='h') city_map.drawcoastlines() city_map.drawmapboundary(fill_color='#99ffff') city_map.fillcontinents(color='#804000', lake_color='#009799') city_map.drawrivers(color='b') city_map.readshapefile('./Databases/districts/geo_fthy-xz3r-1', 'district_m') # Label Lake michigan lat_lake, lon_lake = 42.008124, -87.567399 x_lake, y_lake = city_map(lon_lake, lat_lake) plt.text(x_lake, y_lake, 'Lake Michigan', fontsize=10, fontweight='bold', va='bottom', ha='center', color='k') return city_map
def _plot_basemap(bm_params, drawlonlatlines=False, coastlinecolor=(1, 1, 1), countrycolor=(0.3, 0.3, 0.3), continentcolor=(1, 1, 1), lakecolor=(0.7, 0.7, 0.7), rivercolor=(0.7, 0.7, 0.7), mapboundarycolor=(0.7, 0.7, 0.7)): bm = Basemap(**bm_params) if coastlinecolor is not None: bm.drawcoastlines(color=coastlinecolor, zorder=0.1) if countrycolor is not None: bm.drawcountries(countrycolor, zorder=0.2) if rivercolor is not None: bm.drawrivers(zorder=0.2, color=rivercolor) if continentcolor is not None: bm.fillcontinents(color=continentcolor, lake_color=lakecolor, zorder=0) if mapboundarycolor is not None: bm.drawmapboundary(fill_color=mapboundarycolor, zorder=-1) if drawlonlatlines: bm.drawmeridians(np.linspace(bm.llcrnrlon, bm.urcrnrlon, 10), color=(0.5, 0.5, 0.5), linewidth=0.5, labels=[1, 0, 0, 1], fmt="%.1f", fontsize=6) bm.drawparallels(np.linspace(bm.llcrnrlat, bm.urcrnrlat, 10), color=(0.5, 0.5, 0.5), linewidth=0.5, labels=[1, 0, 0, 1], fmt="%.1f", fontsize=6) return bm
def GPSplotter(pathstring): ## IMPORT DATA ## for lat, long, time ################################################### with open(pathstring, 'rt') as datafile: datareader = csv.reader(datafile, delimiter = ',', quotechar = '|') lat = [] lon = [] time = [] for row in datareader: lat.append(row[0]) lon.append(row[1]) if len(row)>2: time.append(row[2]) #measurements.append([row[3], row[4], row[1]]) # [LAT,LONG,TSTAMP] try : lat[0] = float(lat[0]) lon[0] = float(lon[0]) time[0] = iso8601.parse_date(time[0]) except: del lat[0] del lon[0] if len(time)>0: del time[0] for i in range(len(lat)): try : lat[i] = float(lat[i]) lon[i] = float(lon[i]) except ValueError: print("Are your cols in form lat, long, time?") break if len(time)>0: try: time[i] = iso8601.parse_date(time[i]) except: time[i] = 0 ################################################### latLL = min(lat) lonLL = min(lon) latUR = max(lat) lonUR = max(lon) map = Basemap(projection='merc' ,llcrnrlon= lonLL - 1,llcrnrlat=latLL -1 , urcrnrlon= lonUR+1,urcrnrlat= latUR+1,resolution='h') # draw coastlines, country boundaries, fill continents. map.drawcoastlines(linewidth=0.5) map.drawcountries(linewidth=0.5) # map.fillcontinents(color='coral',lake_color='aqua') # draw the edge of the map projection region (the projection limb) #map.drawmapboundary(fill_color='aqua') # draw lat/lon grid lines every 30 degrees. map.drawmeridians(np.arange(0,360,1)) map.drawparallels(np.arange(-90,90,1)) #map.bluemarble() #NASA image - kek map.drawrivers(linewidth=0.5) map.scatter(lon,lat, latlon = True) plt.show()
def generate_map(self, location): path = os.path.join(settings.PROJ_DIR, 'www', 'maps', '%s.png' % location['code']) figprops = { 'dpi': 200, 'facecolor': '#a5bfdd', 'figsize': (8,8), 'frameon': False, } fig = plt.figure(1, **figprops) fig.clear() plt.cla() ax = fig.add_axes((0,0,1,1)) for sp in ax.spines.itervalues(): sp.set_linewidth(0.0) centroid = location['geo']['centroid'] map_config = { 'projection': 'lcc', 'resolution': 'h', 'width': 200000, # map width in meters 'height': 200000, # map height in meters 'lat_0': centroid[0], # latitude center of map 'lon_0': centroid[1], # longitude center of map # 'llcrnrlon': , # lower left longitude # 'llcrnrlat': , # lower left latitude # 'urcrnrlon': , # upper right longitude # 'urcrnrlat': , # upper right latitude } m = Basemap(**map_config) m.drawcoastlines(linewidth=0, color='#6993a6') m.drawmapboundary(fill_color='#a5bfdd') m.drawstates(linewidth=1.0, color='#7f7f7f') m.drawrivers(linewidth=1.0, color='#a5bfdd') m.fillcontinents(color='#f4f3f0', lake_color='#a5bfdd') m.readshapefile('/Users/Jeremy/Downloads/_/in15oc03/in101503', 'roadways', drawbounds=True, color="#999999", linewidth=1.0) # if location['code'] in self.shapes: # for shape in self.shapes[location['code']]: # poly = plt.Polygon(shape, facecolor="g", edgecolor="k", alpha=0.5) # plt.gca().add_patch(poly) if os.path.exists(path): os.unlink(path) #fig.draw() fig.savefig(path, format='png', bbox_inches='tight')
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
def maps(station_list, origin, strike, dip, rake, plot_file): """ Plotting a map with epicenter and possible stations according to distance and a map with with the beachball """ # sets figure's dimensions _fig_x = 10 _fig_y = 10 fig = plt.figure(figsize=(_fig_x,_fig_y)) # calculating map space _max = max(_station.distance_by_origin for _station in station_list) _max = int(round(_max * 1000 *2)) _size = _max + int(round(_max/7.0)) _diff = kilometer2degrees(round(_size/(2*2.0*1000))) parallels = [round(origin.latitude,2), round((origin.latitude-_diff),2), round((origin.latitude+_diff),2)] meridians = [round(origin.longitude,2), round((origin.longitude-_diff),2), round((origin.longitude+_diff),2)] m = Basemap(projection='laea', lat_0 = origin.latitude, lon_0 = origin.longitude, lat_ts=origin.latitude, resolution = 'i', area_thresh = 0.1, width = _size, height = _size) m.drawparallels(parallels,labels=[1,0,0,0], color='grey', fontsize=10) m.drawmeridians(meridians,labels=[0,0,0,1], color='grey', fontsize=10) m.drawrivers(color='aqua') m.drawcoastlines(color='0.2') m.drawcountries(color='0.4') m.drawmapboundary(fill_color='aqua') m.fillcontinents(color='coral',lake_color='aqua') x,y = m(origin.longitude, origin.latitude) # epicenter m.scatter(x, y, 1, color="#FFFF00", marker="*", zorder=3, linewidths=2, edgecolor="k") # beachball ax = plt.gca() b = beach.beach([strike, dip, rake], xy=(x,y), width=35000, linewidth=1, facecolor='r') b.set_zorder(10) ax.add_collection(b) # stations for station in station_list: x,y = m(station.longitude, station.latitude) m.scatter(x, y, 150, color="#33CC00", marker="^", zorder=3, linewidths=1, edgecolor="k") plt.text(x+1800, y+3000, station.code, family="monospace", fontsize=12) fig.savefig(plot_file)
def plot_station_locs(stations,target_latlon): import matplotlib.pyplot as plt from mpl_toolkits.basemap import Basemap import numpy as np # "unpack" data from air quality object #print(aq_obj.monitor_info) #monitor_info = aq_obj.monitor_info my_lon = stations['Longitude'][0] my_lat = stations['Latitude'][0] r_max = 150 #param_code = aq_obj.param #site_name = aq_obj.site_name num_stations = len(stations) # create colors to correspond to each of the stations RGB_tuples = [(x/num_stations, (1-x/num_stations),.5) for x in range(0,num_stations)] color_dict = {} for x in range(0,num_stations): color_dict[stations.index[x]] = RGB_tuples[x] # set viewing window for map plot scale_factor = 60.0 # lat/lon coords to show from center point per km of r_max left_lim = my_lon-r_max/scale_factor right_lim = my_lon+r_max/scale_factor bottom_lim = my_lat-r_max/scale_factor top_lim = my_lat+r_max/scale_factor fig = plt.figure(figsize=(20, 12), facecolor='w') m = Basemap(projection='merc',resolution='c',lat_0=my_lat,lon_0=my_lon,llcrnrlon=left_lim,llcrnrlat=bottom_lim,urcrnrlon=right_lim,urcrnrlat=top_lim) m.shadedrelief() m.drawstates() m.drawcountries() m.drawrivers() m.drawcoastlines() plt.show() # plot each EPA site on the map, and connect it to the soiling station with a line whose width is proportional to the weight for i in range(0,num_stations): (x,y) = m(stations.iloc[i]['Longitude'],stations.iloc[i]['Latitude']) m.plot(x,y,'o',color = RGB_tuples[i]) (x,y) = m(stations.iloc[i]['Longitude'],stations.iloc[i]['Latitude']) plt.text(x,y,stations.index[i]) (x,y) = m(target_latlon[1],target_latlon[0]) m.plot(x,y,'x',color = 'r',ms=8) return fig
def print_schematic(self,datadir='model/data_nlp.csv',ts_condensed=False): # ************* # Plot simplified and detailed network schematic and plant locations on a map # ************* from mpl_toolkits.basemap import Basemap # requires Basemap installation plt.style.use('bmh') from graphviz import Digraph # requires graphviz installation print('printing network schematics') # plot condensed network g = Digraph('G',format='pdf',filename='schematic/network_schematic.gv') g.attr(size='6,6',label='Simplified Network Schematic',fontsize='12') g.node_attr.update(color='lightblue2', style='filled',shape='ellipse') for n in self.network_conn: g.edge(n[0], n[1]) g.view() # whole detailed network detailed_network=pd.read_csv(datadir) g = Digraph('G',format='pdf',filename='schematic/detailed_network.gv') g.attr(label='Detailed Network Schematic',fontsize='20') for l in detailed_network.index: if ts_condensed: # remove time step info and represent as another link (for simplicity) g.edge(detailed_network['i'][l].split('.')[0], detailed_network['j'][l].split('.')[0]) else: # print all nodes and links g.edge(detailed_network['i'][l], detailed_network['j'][l]) g.view() # plot facilities locations on a map fig = plt.figure(figsize=(5.5,5)) ax = plt.gca() # change resolution to i: intermadiate for faster plotting. (i: intermediate, h: high) m = Basemap(projection='merc',llcrnrlon=-125,llcrnrlat=32,urcrnrlon=-113,urcrnrlat=42.5,resolution='h') m.drawcoastlines() m.drawstates() m.drawcountries() # parallels = np.arange(30,45,5.) # make latitude lines # meridians = np.arange(-125,-110,5.) # make longitude lines # m.drawparallels(parallels,labels=[1,0,0,0],fontsize=9,alpha=0.4,color='gray') # m.drawmeridians(meridians,labels=[0,0,0,1],fontsize=9,alpha=0.4,color='gray') m.drawlsmask(land_color='Linen',ocean_color='lightblue',lakes=True,resolution = 'h') m.drawrivers(linewidth=0.5, linestyle='solid', color='dodgerblue', zorder=1) # m.shadedrelief(scale=0.7,alpha=0.6) # add topography for i,key in enumerate(self.network_param.keys()): x,y=m(self.network_param[key]['lon'],self.network_param[key]['lat']) m.scatter(x,y,marker='o',alpha=0.7,s=self.network_param[key]['capacity_MW']/5,label=key+' ('+str(int(round(self.network_param[key]['capacity_MW'],0)))+' MW)') plt.legend(fontsize=9,loc=1) m.drawmapscale(-123,33,0,0,200,fontsize=8) plt.title('Modeled hydropower plants', loc='left', fontweight='bold') plt.tight_layout() plt.savefig('schematic/schematic.pdf',transparent=True) plt.close(fig) print('model schematics have been saved')
def print_map(coord, res='c', arrn_lim=1, title_map='Paris', l_size=10, l_color='blue', l_alf=0.4): fig, ax = plt.subplots(figsize=(25, 10)) #12.5,5)) # 25/10 m = Basemap(projection='cyl', resolution=res, llcrnrlon=2.25, llcrnrlat=48.813500, urcrnrlon=2.421, urcrnrlat=48.906000) m.drawrivers(color='lightblue', linewidth=2) # Insert Paris background image img = mpimg.imread('../images/Paris_map.jpg') im = m.imshow(img, extent=(2.25, 2.45, 48.797622, 48.925604), alpha=0.4, zorder=1, origin='upper') # Arrondissements limits if arrn_lim: plat, plon, plabel, colors_per_zip_limit = get_arrondissement_info() arr_xpt, arr_ypt = m(plon, plat) m.scatter(arr_xpt, arr_ypt, s=100, c=colors_per_zip_limit, zorder=3, marker='X') # Insert Listings if not l_size: breakpoints = [100, 200, 1000, 10000] coord['price_cat'] = coord.price.apply(get_price_interval) coord['price_size'] = coord.price_cat.apply( lambda x: (breakpoints.index(x) * 15)) l_size = coord.price_size.values if not l_color: l_color = coord['zipcode'].apply(lambda x: cpzl[x]) lis_xpt, lis_ypt = m(coord.longitude.values, coord.latitude.values) m.scatter(lis_xpt, lis_ypt, s=l_size, c=l_color, zorder=2, alpha=l_alf) plt.title(title_map) plt.show() fig.savefig('../images/EDA_Arrondissements.png', bbox_inches='tight')
def _basemap_district(min_lat, min_lon, max_lat, max_lon): """ This function creates a Basemap instance that is a map of a District of chicago :param min_lat, min_lon, max_lat, max_lon: integers or floats representing vertices of the map :return district_map """ district_map = Basemap(llcrnrlon=min_lon, llcrnrlat=min_lat, urcrnrlon=max_lon, urcrnrlat=max_lat, projection="merc", resolution = 'h') district_map.drawcoastlines() district_map.drawcountries() district_map.drawcounties() district_map.drawmapboundary() district_map.drawrivers(color='#0000ff') return district_map
def display_map(self, colourmap: Union[str, Colormap, None] = None, legend_loc: Union[str, int, None] = None, legend_fontsize: int = 14) -> None: """ Uses matplotlib to display the map Requires matplotlib and basemap to be installed basemap.in order to function """ from mpl_toolkits.basemap import Basemap from matplotlib.patches import Patch import matplotlib.pyplot as plt colourmap = "viridis_r" if colourmap == None else colourmap legend_loc = "best" if legend_loc == None else legend_loc assert legend_loc in LEGEND_LOCATIONS plt.figure(figsize=FIGSIZE) m = Basemap(projection="merc", resolution="i", llcrnrlat=self._lat_min, llcrnrlon=self._lon_min, urcrnrlat=self._lat_max, urcrnrlon=self._lon_max) m.drawcountries() m.fillcontinents(color="white", lake_color="#1c9ef7", alpha=.1) m.drawcoastlines() m.drawrivers(color="#1c9ef7") if self._mode == MODES[0]: m.imshow(self.grid, alpha=1, vmin=0, vmax=len(COLOURS), cmap=get_unified_colourmap()) legend_items = [] for name, value in self._legend.items(): legend_items.append(Patch(color=COLOURS[value - 1], label=name)) plt.legend(handles=legend_items, loc=legend_loc, fontsize=legend_fontsize) elif self._mode == MODES[1]: img = m.imshow(self.grid, alpha=1, cmap=colourmap) plt.colorbar(img) plt.title(list(self._legend.keys())[0], size=30) plt.show()
def _display_gps_map(self, df, labels, map_title): '''print the longitude & latitude GPS coordinates of the dataframe within the map bounderies''' print("GIS_Map_Viz: _display_gps_map ...") fig = plt.figure(figsize=(20, 10)) plt.title(map_title) m = Basemap(projection='merc', llcrnrlat=self.gps_bounderies_dict['lat_min'] - 0.5, urcrnrlat=self.gps_bounderies_dict['lat_max'] + 0.5, llcrnrlon=self.gps_bounderies_dict['lon_min'] - 0.5, urcrnrlon=self.gps_bounderies_dict['lon_max'] + 0.5, resolution='i') # Reference: https://matplotlib.org/basemap/users/geography.html m.drawmapboundary(fill_color='#85A6D9') m.drawcoastlines(color='#6D5F47', linewidth=.8) m.drawrivers(color='green', linewidth=.4) m.shadedrelief() m.drawcountries() m.fillcontinents(lake_color='aqua') mycmap = matplotlib.colors.LinearSegmentedColormap.from_list( "", ["green", "yellow", "red"]) longitudes = df[self.longitude_feature_name].tolist() latitudes = df[self.latitude_feature_name].tolist() if labels is None: labels = 'darkblue' wp = mpatches.Patch(color='darkblue', label='water points') plt.legend(handles=[wp], title='Location') else: labels = labels.cat.codes wp_functional = mpatches.Patch(color='green', label='water points: functional') wp_need_repair = mpatches.Patch( color='red', label='water points: non functional') wp_non_functional = mpatches.Patch( color='yellow', label='water points: functional needs repair') plt.legend( handles=[wp_functional, wp_need_repair, wp_non_functional], title='Location and Status') m.scatter(longitudes, latitudes, s=0.05, zorder=2, latlon=True, c=labels, cmap=mycmap) plt.show()
def draw_eastasia(): size = 6500*1000 # 6500km plt.figure(figsize=(10, 10), facecolor='w') m = Basemap(width=size,height=size, projection='lcc', resolution='c', lat_0=35.5, lon_0=103.3) m.drawcoastlines(linewidth=0.3, antialiased=False, color='#202020') # 海岸线 m.drawrivers(linewidth=0.05, linestyle='-', color=(0.1, 0.1, 0.1), antialiased=False) # 河流 m.drawcountries(linewidth=1, linestyle='-.', antialiased=False) # 国界 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, dashes=[2,2]) # 绘制子午线 # m.etopo() # 地形高程 m.bluemarble() plt.tight_layout(4) plt.title('东亚及附近区域遥感图', fontsize=21) # 东亚及附近区域地理地形图 plt.show()
def draw_terrain_height_map(self, fig, ax, vmin=None, vmax=None, lat_spacing=None, lon_spacing=None): '''Draw the terrain heights''' if vmin is None: topomin = 0.05 else: topomin = vmin / 1000. if vmax is None: topomax = 3. else: topomax = vmax / 1000. if lat_spacing is None: lat_spacing = 1. if lon_spacing is None: lon_spacing = 1. bm1 = Basemap(projection='cea', resolution='l', area_thresh=10000., llcrnrlon=self.minlon, urcrnrlon=self.maxlon, llcrnrlat=self.minlat, urcrnrlat=self.maxlat, ax=ax) ax.set_title('Terrain within %02d km of Radar (km)' % (self.range), fontdict=TITLEDICT) bm1.drawmeridians(np.arange(self.minlon, self.maxlon, lon_spacing), labels=[1, 0, 0, 1]) bm1.drawparallels(np.arange(self.minlat, self.maxlat, lat_spacing), labels=[1, 0, 0, 1]) bm1.drawcountries() bm1.drawcoastlines() bm1.drawrivers() xbm1, ybm1 = bm1(self.lon, self.lat) Htmap = bm1.pcolormesh(xbm1, ybm1, self.topo / 1000., vmin=topomin, vmax=topomax, cmap=self.terr_cmap) bm1.plot(self.rlon, self.rlat, 'rD', latlon=True) #plot_range_ring(50., bm=bm1, color='w') fig.colorbar(Htmap, ax=ax)
def plot(): """ This methods reads in neighbourhood data from the file data/neighbourhood.csv and create a file seattle_prices.png, that contains a Geoplot of Seattle Airbnb prices. :return: None """ df = pd.read_csv("data/neighbourhood.csv", sep=";") fig, ax = plt.subplots(figsize=(20, 20)) m = Basemap(projection='lcc', resolution='h', lat_0=47.63, lon_0=-122.3, width=2E4, height=3E4) m.drawcoastlines() m.drawrivers() m.drawstates() lon = df['longitude'].values lat = df['latitude'].values price = df['price'].values count = df['count'].values neighbourhood = df['neighbourhood'].values m.scatter(lon, lat, latlon=True, c=price, s=count / 15, cmap='Reds') cbar = plt.colorbar(label='Price') cbar.ax.set_ylabel('Price', fontsize=20) for i, txt in enumerate(neighbourhood): x, y = m(lon[i], lat[i]) plt.text(x, y, txt) ax.set_xlabel('Longitude', fontsize=20) ax.set_ylabel('Latitude', fontsize=20) plt.title('Seattle Airbnb Prices', fontsize=40) ax.xaxis.label.set_size(20) ax.yaxis.label.set_size(20) for a in [100, 1000, 5000]: plt.scatter([], [], c='red', alpha=0.5, s=a / 15, label=str(a)) plt.scatter([], [], c='red', alpha=0.5, s=0, label='Bookings') plt.legend(scatterpoints=1, frameon=False, labelspacing=1, loc='lower right') plt.savefig('seattle_prices.png')
def draw_map(lats, lons, limits, px_size, resolution): print('drawing map...') fig_size = px_size // 100 figure = matplotlib.pyplot.figure(figsize=(fig_size, fig_size)) basemap = Basemap(limits[0], limits[1], limits[2], limits[3], lon_0=limits[4], lat_0=limits[5], resolution=resolution, projection='tmerc') print('drawing map features...') basemap.drawcoastlines() basemap.drawstates() basemap.drawrivers() basemap.fillcontinents(color='0.99', zorder=0) figure.tight_layout() return figure, basemap
class MapCreator: def __init__(self): self.stations = stat.Stations( "../data/stanice_shp/stanice_projekt.shp", "../data/stanice_meteo/met_stanice.csv") self.map = None self.pocetM = 0 self.pocetP = 0 def addMeteoStations(self): lons = [] lats = [] for stanica in self.stations.getStationsMeteo(): lons.append(stanica.getLongtitude()) lats.append(stanica.getLatitude()) self.pocetM += 1 x, y = self.map(lons, lats) self.map.plot(x, y, 'rx', markersize=5) def addPollutantStations(self): lons = [] lats = [] for stanica in self.stations.getStationsPol(): lons.append(stanica.getLongtitude()) lats.append(stanica.getLatitude()) self.pocetP += 1 x, y = self.map(lons, lats) self.map.plot(x, y, 'g+', markersize=6) def _buildMap(self, res='l'): self.map = Basemap(projection='mill', llcrnrlat=47.65, llcrnrlon=16.77, urcrnrlat=49.65, urcrnrlon=22.65, resolution=res) self.map.fillcontinents(color='white', lake_color='blue') self.map.drawcountries(color="black") self.map.drawrivers(color='blue') def showAllStations(self): self._buildMap('h') self.addMeteoStations() self.addPollutantStations() plt.tight_layout() plt.title("SHMU stations") plt.savefig('stations.png', dpi=900) plt.show()
def plot_stations_map(ax, stns, noText=False): # determine range to print based on min, max lat and lon of the data lat = list(stns['latitude']) lon = list(stns['longitude']) siz = [(2)**(x / 1000) for x in stns['flow_count']] margin = 0.01 # buffer to add to the range lat_min = min(lat) - margin lat_max = max(lat) + margin lon_min = min(lon) - margin lon_max = max(lon) + margin # create map using BASEMAP m = Basemap( llcrnrlon=lon_min, llcrnrlat=lat_min, urcrnrlon=lon_max, urcrnrlat=lat_max, lat_0=(lat_max - lat_min) / 2, lon_0=(lon_max - lon_min) / 2, projection='lcc', resolution='f', ) m.drawcoastlines() m.fillcontinents(lake_color='aqua') m.drawmapboundary(fill_color='aqua') m.drawrivers() # convert lat and lon to map projection coordinates lons, lats = m(lon, lat) # plot points as red dots if noText: ax.scatter(lons, lats, marker='o', color='r', zorder=5, alpha=0.6, s=1) return else: ax.scatter(lons, lats, marker='o', color='r', zorder=5, alpha=0.3, s=siz) # annotate popular stations for i in range(len(siz)): if siz[i] >= 2**6: plt.text(lons[i], lats[i], text[i])
def plot_station_positions(stations, img_file="stfl_station_positions.png", shp_paths=None, min_lon=-180., min_lat=-90., max_lon=180., max_lat=90.): lons = [] lats = [] st_ids = [] for s in stations: assert isinstance(s, Station) lons.append(s.longitude) lats.append(s.latitude) st_ids.append(s.id) b = Basemap(llcrnrlon=min_lon, llcrnrlat=min_lat, urcrnrlon=max_lon, urcrnrlat=max_lat, resolution="h", area_thresh=0) x, y = b(lons, lats) fig = plt.figure() nrows = 1 ncols = 1 gs = GridSpec(nrows, ncols) ax = fig.add_subplot(gs[0, 0]) b.scatter(x, y, c="b", s=20) b.drawcoastlines() b.drawrivers(color="b") if shp_paths is not None: for shp_path in shp_paths: b.readshapefile(shp_path[:-4], "basin_info", color="m", linewidth=0.5) for xi, yi, st_id in zip(x, y, st_ids): ax.annotate(st_id, (xi, yi)) fig.savefig(img_file, bbox_inches="tight", dpi=400)
def render_map(grb_file, llclat, llclon, urclat, urclon, altitude_layer): """Given a grb file, renders a jpg map on disk.""" print('processing file %s ' % grb_file) grbs = pygrib.open(grb_file) data = grbs.select(name='Temperature')[altitude_layer]['values'] plt.figure(figsize=(12, 12)) # We don't like the way noaa aligns things. We like monotonic variations. data = realign_noaa_data(data) lonlat2temp = interpolate.interp2d(ALL_LONS, ALL_LATS, data, kind='linear') lats_interp = np.arange(llclat, urclat, 0.01) lons_interp = np.arange(llclon, urclon, 0.01) data_interp = lonlat2temp(lons_interp, lats_interp) # Size of the img to render in meters. width, height = width_height_from_bbox(llclat, llclon, urclat, urclon) m = Basemap( projection='cass', lat_ts=10, lat_0=(urclat + llclat) / 2, lon_0=(llclon + urclon) / 2, resolution='i', width=width, height=height) x, y = m(*np.meshgrid(lons_interp, lats_interp)) # Draw plenty of fancy stuff m.drawstates() m.drawcountries() m.drawlsmask() m.drawrivers() m.drawcoastlines() m.shadedrelief() m.drawparallels(np.arange(-90., 120., 30.), labels=[1, 0, 0, 0]) m.drawmeridians(np.arange(-180., 180., 60.), labels=[0, 0, 0, 1]) m.pcolormesh( x, y, data_interp, shading='flat', cmap=plt.cm.jet, alpha=0.05, vmin=260, vmax=305) m.colorbar(location='right') plt.title('Temperature') image = '%s.jpg' % grb_file plt.savefig(image) plt.close()
def plot_merc(resolution,llcrnrlon,llcrnrlat,urcrnrlon,urcrnrlat,topo=True): warnings.filterwarnings("ignore",category=matplotlib.cbook.mplDeprecation) plt.figure(figsize=(8,8)) map = Basemap(projection='merc',resolution = resolution, area_thresh = 1000., llcrnrlon=llcrnrlon, llcrnrlat=llcrnrlat,urcrnrlon=urcrnrlon, urcrnrlat=urcrnrlat) if topo: plot_topo(map,cmap=plt.cm.rainbow) map.drawcoastlines(color='k',linewidth=0.5) # map.fillcontinents() map.drawcountries(color='k',linewidth=0.1) map.drawstates(color='gray',linewidth=0.05) map.drawrivers(color='blue',linewidth=0.05) map.drawmapboundary() map.drawparallels(np.linspace(llcrnrlat,urcrnrlat,5,dtype='int16').tolist(),labels=[1,0,0,0],linewidth=0) map.drawmeridians(np.linspace(llcrnrlon,urcrnrlon,5,dtype='int16').tolist(),labels=[0,0,0,1],linewidth=0) return map
def addcardgrdcnew(stname, chem_GRDC, basin, chem_grdc_rd="", doublebar=True): """ Add the map with the indication of the station next to the graphic. k: int, index of the station fig: axis of the figure to plot the map """ namegr = importGRDCname(chem_GRDC) i = stgrdcindex(stname, namegr) - 1 # car index commence à 1 lon = importvariable(chem_GRDC, "lon", 1)[i] lat = importvariable(chem_GRDC, "lat", 1)[i] ibas = np.where(Basins == basin)[0][0] Lbas = Basins[ibas] if doublebar: ax2 = plt.subplot2grid((3, 10), (2, 8), colspan=2) else: ax2 = plt.subplot2grid((3, 10), (2, 7), colspan=3) m = Basemap(projection="cyl", llcrnrlon=float(Lbas[1]), llcrnrlat=float(Lbas[2]), \ urcrnrlon=float(Lbas[3]), urcrnrlat= float(Lbas[4]), resolution="i") m.arcgisimage(server='http://server.arcgisonline.com/ArcGIS', service='World_Physical_Map', epsg=3000, xpixels=300, dpi=300, verbose=True) m.drawcountries(linewidth=0.25) m.drawcoastlines(linewidth=0.25) m.drawrivers(linewidth=0.15, color="b") ax2.plot([lon], [lat], 'o', markersize=2, color='r') if chem_grdc_rd != "": namegr = importGRDCname(chem_GRDC) index = stgrdcindex(stname, namegr) mask = getstn_grdc_rd(chem_grdc_rd, index) lons = importvariable(chem_grdc_rd, "lon", 1) lats = importvariable(chem_grdc_rd, "lat", 1) lon, lat = np.meshgrid(lons, lats) xi, yi = m(lon, lat) # Voir si fonctionne ou si grille trop grande ne se grafique pas m.contourf(xi, yi, mask, cmap=plt.get_cmap("Blues")) ax2.plot() return
def _basemap_city(): """ This function creates a Basemap instance that is a map of Chicago with its districts :return city_map """ city_map = Basemap(llcrnrlon=-87.946463888372286, llcrnrlat=41.62846088888256, urcrnrlon=-87.415897644283177, urcrnrlat=42.042643093713917, projection="merc", resolution = 'h') city_map.drawcoastlines() city_map.drawmapboundary(fill_color='#99ffff') city_map.fillcontinents(color='#804000', lake_color='#009799') city_map.drawrivers(color='b') city_map.readshapefile('./Databases/districts/geo_fthy-xz3r-1', 'district_m') # Label Lake michigan lat_lake, lon_lake = 42.008124, -87.567399 x_lake, y_lake = city_map(lon_lake, lat_lake) plt.text(x_lake, y_lake, 'Lake Michigan', fontsize=10, fontweight='bold', va='bottom', ha='center', color='k') return city_map
def generate_fairbanksbase(): mm = Basemap( width=300000, height=200000, resolution='f', projection='aea', lat_1=60., lat_2=70., lat_0=fairbanks_lat, lon_0=fairbanks_lon) mm.drawcoastlines() mm.drawrivers(color=water, linewidth=1.5) mm.drawmeridians(np.arange(-180, 180, 2), labels=[False, False, False, 1]) mm.drawparallels(np.arange(0, 80, 1), labels=[False, 1, False, False]) mm.fillcontinents( color=earth, lake_color=water) mm.drawmapboundary(fill_color=water) mm.readshapefile( "/Volumes/SCIENCE/GIS_Data/catalog.data.gov/tl_2013_02_prisecroads/tl_2013_02_prisecroads", 'roads', color="slategrey", linewidth=2) return mm
def draw_map(countries_results): # Open the data file containing countries' latitudes and longitudes data_file = open('country_latlon.csv') #Creation of a dictionary with these data world = dict() for line in data_file.readlines(): fields = line.split(',') world[fields[0]] = (fields[1], fields[2].strip()) # Store the latitudes, longitudes and the frequency appearance of each country in the appropriate lists N = 8 #The number of countries that are going to printed on the map lons = [] lats = [] attacks_size = [] for i in range(N): lats.append(float(world[countries_results[0][i]][0])) lons.append(float(world[countries_results[0][i]][1])) attacks_size.append(countries_results[1][i]/sum_countries) sum_countries = sum(countries_results[1]) # --- Build Map --- worldmap = Basemap(projection='mill', resolution = 'i', area_thresh = 100000.0, lat_0=0, lon_0=0) worldmap.drawcoastlines(color = 'ForestGreen') worldmap.drawcountries(linewidth =1, color = 'ForestGreen') worldmap.drawmapboundary(fill_color = 'Snow') worldmap.drawrivers(color = 'Snow') worldmap.fillcontinents(color = 'Snow', lake_color='Snow') n = 0 for lon, lat, attack in zip(lons, lats, attacks_size): if attack>0.1: n=20 else: n=10 x,y = worldmap(lon, lat) worldmap.plot(x, y, 'ro', markersize = n) plt.show() return
def draw_terrain_height_map(self, fig, ax, vmin=None, vmax=None, lat_spacing=None, lon_spacing=None): """Draw the terrain heights""" if vmin is None: topomin = 0.05 else: topomin = vmin / 1000.0 if vmax is None: topomax = 3.0 else: topomax = vmax / 1000.0 if lat_spacing is None: lat_spacing = 1.0 if lon_spacing is None: lon_spacing = 1.0 bm1 = Basemap( projection="cea", resolution="l", area_thresh=10000.0, llcrnrlon=self.minlon, urcrnrlon=self.maxlon, llcrnrlat=self.minlat, urcrnrlat=self.maxlat, ax=ax, ) ax.set_title("Terrain within %02d km of Radar (km)" % (self.range), fontdict=TITLEDICT) bm1.drawmeridians(np.arange(self.minlon, self.maxlon, lon_spacing), labels=[1, 0, 0, 1]) bm1.drawparallels(np.arange(self.minlat, self.maxlat, lat_spacing), labels=[1, 0, 0, 1]) bm1.drawcountries() bm1.drawcoastlines() bm1.drawrivers() xbm1, ybm1 = bm1(self.lon, self.lat) Htmap = bm1.pcolormesh(xbm1, ybm1, self.topo / 1000.0, vmin=topomin, vmax=topomax, cmap=self.terr_cmap) bm1.plot(self.rlon, self.rlat, "rD", latlon=True) # plot_range_ring(50., bm=bm1, color='w') fig.colorbar(Htmap, ax=ax)
def plotar_mapa_base(self): m = Basemap(projection='cyl', llcrnrlat=self.lat.min()-1, urcrnrlat=self.lat.max()+1, llcrnrlon=self.lon.min()-1, urcrnrlon=self.lon.max()+1, lat_ts=0, resolution='i') mlon, mlat = m(self.lon, self.lat) plt.figure(facecolor='w', figsize=(6, 8)) m.bluemarble() m.plot(mlon, mlat, '.y', markersize=10) m.drawstates(linewidth=3) m.drawrivers() m.drawcoastlines() m.drawparallels(np.arange(-25, -10, 2), color='gray', dashes=[1, 1], labels=[1, 1, 0, 0]) m.drawmeridians(np.arange(-60, 10, 3), color='gray', dashes=[1, 1], labels=[0, 0, 1, 1]) plt.show()
def grid_plot(self): """ function for visualizing the generated grid """ lon, lat, dx, dy = self.rectilinear(self.nx,self.ny) pdb.set_trace() west=-95.42; east=-93.94 south=28.39; north=29.90 fig = plt.figure(figsize=(10,10)) 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.drawcounties() basemap.drawstates() basemap.drawrivers(color='b') llons, llats=basemap(lon,lat) basemap.plot(llons, llats, color='k', ls='-', markersize=.5) basemap.plot(llons.T, llats.T, color='k', ls='-', markersize=.5) plt.show()