from owslib.wms import WebMapService url = 'http://mesonet.agron.iastate.edu/cgi-bin/wms/goes/conus_ir.cgi?' wms = WebMapService(url) layers = list(wms.contents) print 'Request type: {}'.format(wms.identification.type) print 'Request title: {}'.format(wms.identification.title) print 'Available layers: {}'.format(layers) layer = layers[1] print 'Layer title: {}'.format(wms[layer].title) print 'Bounding box: {}'.format(wms[layer].boundingBoxWGS84) print 'Projection: {}'.format(wms[layer].crsOptions) import cartopy.crs as ccrs import matplotlib.pyplot as plt us_extent = [-126.0, -66.0, 24.0, 50.0] def set_up_axes(proj, coast_colour='y', extent=us_extent): fig = plt.figure(figsize=(14, 9)) ax = plt.axes(projection=proj) ax.coastlines(color=coast_colour) ax.set_extent(extent, crs=ccrs.PlateCarree()) return ax proj = ccrs.PlateCarree() ax = set_up_axes(proj) ax.add_wms(url, layer) plt.show() import matplotlib.patheffects as mpath # Set up the axes and add a WMS layer, as above. proj = ccrs.PlateCarree() ax = set_up_axes(proj) ax.add_wms(url, layer) # Add the locations of our three cities. cities = {'Washington DC': [38.928, -76.981], 'Austin': [30.308, -97.753], 'San Francisco': [37.758, -122.438],} city_red = '#b80000' for name, latlon in cities.iteritems(): plt.scatter(latlon[1], latlon[0], c=city_red, s=50, linewidths=0, marker='*') plt.text(latlon[1]-1.0, latlon[0]+1.0, name, color='w', size=12, path_effects=[mpath.withStroke(linewidth=2, foreground='k')]) plt.show() import iris import iris.quickplot as qplt year_2015 = iris.Constraint(time=lambda cell: cell.point.year == 2015) with iris.FUTURE.context(cell_datetime_objects=True): cube = iris.load_cube(iris.sample_data_path('A1B_north_america.nc'), year_2015) # Set up the axes, add a WMS layer and city locations; all as above. proj = ccrs.PlateCarree() ax = set_up_axes(proj, coast_colour='k') ax.add_wms(url, layer) for name, latlon in cities.iteritems(): plt.scatter(latlon[1], latlon[0], c=city_red, s=50, linewidths=0, marker='*') plt.text(latlon[1]-1.0, latlon[0]+1.0, name, color='w', size=12, path_effects=[mpath.withStroke(linewidth=2, foreground='k')]) # Add the average air temperature data to the plot as a filled contour. qplt.contourf(cube, alpha=0.25) plt.show() proj = ccrs.LambertConformal() ax = set_up_axes(proj, coast_colour='k') ax.add_wms(url, layer) # Now that we've changed projection we need to specify the native projection # of our city locations. for name, latlon in cities.iteritems(): plt.scatter(latlon[1], latlon[0], c=city_red, s=50, linewidths=0, marker='*', transform=ccrs.PlateCarree()) plt.text(latlon[1]-1.0, latlon[0]+1.0, name, color='w', size=12, path_effects=[mpath.withStroke(linewidth=2, foreground='k')], transform=ccrs.PlateCarree()) qplt.contourf(cube, alpha=0.25) plt.show()