Created
May 1, 2014 12:46
-
-
Save rhattersley/8faf6d7347c3331cc7c5 to your computer and use it in GitHub Desktop.
Demonstrate Cartopy WMTS
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from owslib.wmts import WebMapTileService | |
import cartopy.crs as ccrs | |
import matplotlib.pyplot as plt | |
if __name__ == '__main__': | |
url = 'http://map1c.vis.earthdata.nasa.gov/wmts-geo/wmts.cgi' | |
layer_name = 'MODIS_Terra_CorrectedReflectance_TrueColor' | |
extent = (28, 38, 25, 35) | |
axes_extent = (50, 53, 24, 27) | |
resolution = '110m' | |
wmts = WebMapTileService(url) | |
plt.figure(figsize=(10, 10)) | |
ax = plt.subplot(3, 2, 1, projection=ccrs.PlateCarree(), | |
title='Axes empty - default WMTS extent') | |
ax.add_wmts(wmts, layer_name) | |
ax = plt.subplot(3, 2, 2, projection=ccrs.PlateCarree(), | |
title='Axes empty - explicit WMTS extent') | |
ax.add_wmts(wmts, layer_name, extent=extent) | |
ax = plt.subplot(3, 2, 3, projection=ccrs.PlateCarree(), | |
title='Axes w/ extent - default WMTS extent') | |
ax.set_xlim(axes_extent[:2]) | |
ax.set_ylim(axes_extent[2:]) | |
ax.coastlines(resolution=resolution) | |
ax.add_wmts(wmts, layer_name) | |
ax = plt.subplot(3, 2, 4, projection=ccrs.PlateCarree(), | |
title='Axes w/ extent - explicit WMTS extent') | |
ax.set_xlim(axes_extent[:2]) | |
ax.set_ylim(axes_extent[2:]) | |
ax.coastlines(resolution=resolution) | |
ax.add_wmts(wmts, layer_name, extent=extent) | |
ax = plt.subplot(3, 2, 5, projection=ccrs.PlateCarree(), | |
title='Global Axes - default WMTS extent') | |
ax.set_global() | |
ax.coastlines() | |
ax.add_wmts(wmts, layer_name) | |
ax = plt.subplot(3, 2, 6, projection=ccrs.PlateCarree(), | |
title='Global Axes - explicit WMTS extent') | |
ax.set_global() | |
ax.coastlines() | |
ax.add_wmts(wmts, layer_name, extent=extent) | |
plt.show() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment