We'll try this with cartopy (smaller and smoother than basemap?). Let's start by plotting a map:
Credits http://www.geophysique.be/2014/02/25/shaded-relief-map-in-python/
It turns out it works differently now:
http://scitools.org.uk/cartopy/docs/latest/examples/srtm_shading.html
import matplotlib.pyplot as plt
import numpy as np
import cartopy.crs as ccrs
from cartopy.io.img_tiles import GoogleTiles
from cartopy.io.srtm import srtm_composite
%matplotlib inline
# Specify a region of interest, in this case, Sudelfeld Ski Resort (Germany)
lat = 47 + 40 / 60.0 + 30 / 3600.
lon = 12 + 3 / 60.0 + 2 / 3600.
plt.figure(figsize=(10, 10))
ax = plt.subplot(111, projection=ccrs.PlateCarree())
ax.set_extent([12.0, 13.0, 47.0, 48.0])
gg_tiles = GoogleTiles()
ax.add_image(gg_tiles, 10)
plt.scatter(lon, lat, marker=(5, 1), color='red', s=200)
plt.title("Welcome to Sudelfeld")
gl = ax.gridlines(draw_labels=True,)
gl.xlabels_top = False
gl.ylabels_left = False
from cartopy.io.srtm import SRTM3Source, SRTM1Source
SRTM1Source()
<cartopy.io.srtm.SRTM1Source at 0x94eccf8>
import cartopy.io.srtm
import matplotlib.pyplot as plt
import cartopy.crs as ccrs
from cartopy.io.srtm import SRTM3Source
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree())
# Define a raster source which uses the SRTM data and applies the
# shade function when the data is retrieved.
raster = SRTM3Source()
# Add the shaded SRTM source to our map with a grayscale colormap.
ax.add_raster(raster, cmap='Greys')
ax.set_extent([12, 13, 47, 48])
plt.show()
C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py:264: DownloadWarning: Downloading: http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL3.003/2000.02.11/N47E012.SRTMGL3.hgt.zip warnings.warn('Downloading: {}'.format(url), DownloadWarning)
--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) C:\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 305 pass 306 else: --> 307 return printer(obj) 308 # Finally look for special method names 309 method = get_real_method(obj, self.print_method) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig) 226 227 if 'png' in formats: --> 228 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs)) 229 if 'retina' in formats or 'png2x' in formats: 230 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs)) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs) 117 118 bytes_io = BytesIO() --> 119 fig.canvas.print_figure(bytes_io, **kw) 120 data = bytes_io.getvalue() 121 if fmt == 'svg': C:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs) 2178 orientation=orientation, 2179 dryrun=True, -> 2180 **kwargs) 2181 renderer = self.figure._cachedRenderer 2182 bbox_inches = self.figure.get_tightbbox(renderer) C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs) 525 526 def print_png(self, filename_or_obj, *args, **kwargs): --> 527 FigureCanvasAgg.draw(self) 528 renderer = self.get_renderer() 529 original_dpi = renderer.dpi C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self) 472 473 try: --> 474 self.figure.draw(self.renderer) 475 finally: 476 RendererAgg.lock.release() C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer) 1157 dsu.sort(key=itemgetter(0)) 1158 for zorder, a, func, args in dsu: -> 1159 func(*args) 1160 1161 renderer.close_group('figure') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py in draw(self, renderer, inframe) 358 359 return matplotlib.axes.Axes.draw(self, renderer=renderer, --> 360 inframe=inframe) 361 362 def __str__(self): C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe) 2322 2323 for zorder, a in dsu: -> 2324 a.draw(renderer) 2325 2326 renderer.close_group('axes') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\slippy_image_artist.py in draw(self, renderer, *args, **kwargs) 53 located_images = self.raster_source.fetch_raster( 54 ax.projection, extent=[x1, x2, y1, y2], ---> 55 target_resolution=(window_extent.width, window_extent.height)) 56 57 for img, extent in located_images: C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in fetch_raster(self, projection, extent, target_resolution) 121 return [] 122 else: --> 123 img, _, extent = self.combined(min_x, min_y, nx, ny) 124 return [LocatedImage(np.flipud(img), extent)] 125 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in combined(self, lon_min, lat_min, nx, ny) 165 try: 166 tile_img, _, _ = self.single_tile(bottom_left_ll[0] + i, --> 167 bottom_left_ll[1] + j) 168 except ValueError: 169 img[y_img_slice, x_img_slice] = 0 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in single_tile(self, lon, lat) 177 178 def single_tile(self, lon, lat): --> 179 fname = self.srtm_fname(lon, lat) 180 if fname is None: 181 raise ValueError('No srtm tile found for those coordinates.') C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in srtm_fname(self, lon, lat) 147 return None 148 else: --> 149 return self.downloader.path(params) 150 151 def combined(self, lon_min, lat_min, nx, ny): C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in path(self, format_dict) 224 else: 225 # we need to download the file --> 226 result_path = self.acquire_resource(target_path, format_dict) 227 228 return result_path C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in acquire_resource(self, target_path, format_dict) 439 url = self.url(format_dict) 440 --> 441 srtm_online = self._urlopen(url) 442 zfh = ZipFile(six.BytesIO(srtm_online.read()), 'r') 443 C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in _urlopen(self, url) 263 """ 264 warnings.warn('Downloading: {}'.format(url), DownloadWarning) --> 265 return urlopen(url) 266 267 @staticmethod C:\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 161 else: 162 opener = _opener --> 163 return opener.open(url, data, timeout) 164 165 def install_opener(opener): C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 502 http_err = 0 503 args = (dict, proto, meth_name) + args --> 504 result = self._call_chain(*args) 505 if result: 506 return result C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_302(self, req, fp, code, msg, headers) 694 fp.close() 695 --> 696 return self.parent.open(new, timeout=req.timeout) 697 698 http_error_301 = http_error_303 = http_error_307 = http_error_302 C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 508 if http_err: 509 args = (dict, 'default', 'http_error_default') + orig_args --> 510 return self._call_chain(*args) 511 512 # XXX probably also want an abstract factory that knows when it makes C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs) 588 class HTTPDefaultErrorHandler(BaseHandler): 589 def http_error_default(self, req, fp, code, msg, hdrs): --> 590 raise HTTPError(req.full_url, code, msg, hdrs, fp) 591 592 class HTTPRedirectHandler(BaseHandler): HTTPError: HTTP Error 401: Unauthorized
<matplotlib.figure.Figure at 0x704da90>
%debug
> c:\anaconda3\lib\urllib\request.py(590)http_error_default() 588 class HTTPDefaultErrorHandler(BaseHandler): 589 def http_error_default(self, req, fp, code, msg, hdrs): --> 590 raise HTTPError(req.full_url, code, msg, hdrs, fp) 591 592 class HTTPRedirectHandler(BaseHandler): ipdb> a self = <urllib.request.HTTPDefaultErrorHandler object at 0x00000000095F5630> req = <urllib.request.Request object at 0x000000000B3FEE80> fp = <http.client.HTTPResponse object at 0x000000000B3FEF28> code = 401 msg = 'Unauthorized' hdrs = <http.client.HTTPMessage object at 0x000000000B408400> ipdb> u > c:\anaconda3\lib\urllib\request.py(444)_call_chain() 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result ipdb> a self = <urllib.request.OpenerDirector object at 0x00000000095F54E0> chain = {'default': [<urllib.request.HTTPDefaultErrorHandler object at 0x00000000095F5630>], 307: [<urllib.request.HTTPRedirectHandler object at 0x00000000095F5550>], 301: [<urllib.request.HTTPRedirectHandler object at 0x00000000095F5550>], 302: [<urllib.request.HTTPRedirectHandler object at 0x00000000095F5550>], 303: [<urllib.request.HTTPRedirectHandler object at 0x00000000095F5550>]} kind = 'default' meth_name = 'http_error_default' args = (<urllib.request.Request object at 0x000000000B3FEE80>, <http.client.HTTPResponse object at 0x000000000B3FEF28>, 401, 'Unauthorized', <http.client.HTTPMessage object at 0x000000000B408400>) ipdb> u > c:\anaconda3\lib\urllib\request.py(510)error() 508 if http_err: 509 args = (dict, 'default', 'http_error_default') + orig_args --> 510 return self._call_chain(*args) 511 512 # XXX probably also want an abstract factory that knows when it makes ipdb> u > c:\anaconda3\lib\urllib\request.py(582)http_response() 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response ipdb> u > c:\anaconda3\lib\urllib\request.py(472)open() 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response ipdb> u > c:\anaconda3\lib\urllib\request.py(696)http_error_302() 694 fp.close() 695 --> 696 return self.parent.open(new, timeout=req.timeout) 697 698 http_error_301 = http_error_303 = http_error_307 = http_error_302 ipdb> u > c:\anaconda3\lib\urllib\request.py(444)_call_chain() 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result ipdb> u > c:\anaconda3\lib\urllib\request.py(504)error() 502 http_err = 0 503 args = (dict, proto, meth_name) + args --> 504 result = self._call_chain(*args) 505 if result: 506 return result ipdb> u > c:\anaconda3\lib\urllib\request.py(582)http_response() 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response ipdb> u > c:\anaconda3\lib\urllib\request.py(472)open() 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response ipdb> u > c:\anaconda3\lib\urllib\request.py(163)urlopen() 161 else: 162 opener = _opener --> 163 return opener.open(url, data, timeout) 164 165 def install_opener(opener): ipdb> u > c:\anaconda3\lib\site-packages\cartopy\io\__init__.py(265)_urlopen() 263 """ 264 warnings.warn('Downloading: {}'.format(url), DownloadWarning) --> 265 return urlopen(url) 266 267 @staticmethod ipdb> l 260 261 Caller should close the file handle when finished with it. 262 263 """ 264 warnings.warn('Downloading: {}'.format(url), DownloadWarning) --> 265 return urlopen(url) 266 267 @staticmethod 268 def from_config(specification, config_dict=None): 269 """ 270 The ``from_config`` static method implements the logic for acquiring a ipdb> u > c:\anaconda3\lib\site-packages\cartopy\io\srtm.py(441)acquire_resource() 439 url = self.url(format_dict) 440 --> 441 srtm_online = self._urlopen(url) 442 zfh = ZipFile(six.BytesIO(srtm_online.read()), 'r') 443 ipdb> a self = <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D15240> target_path = 'C:\\Users\\FL232714\\.local\\share\\cartopy\\SRTM\\SRTMGL1\\N47E012.hgt' format_dict = {'config': {'downloaders': {('SRTM', 'SRTM3'): <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D0A1D0>, ('shapefiles', 'gshhs'): <cartopy.io.shapereader.GSHHSShpDownloader object at 0x0000000005CAA0B8>, ('shapefiles', 'natural_earth'): <cartopy.io.shapereader.NEShpDownloader object at 0x0000000005C92278>, ('SRTM', 'SRTM1'): <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D15240>}, 'repo_data_dir': 'C:\\Anaconda3\\lib\\site-packages\\cartopy\\data', 'data_dir': 'C:\\Users\\FL232714\\.local\\share\\cartopy', 'pre_existing_data_dir': ''}, 'resolution': 1, 'y': 'N47', 'x': 'E012'} ipdb> p url 'http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL1.003/2000.02.11/N47E012.SRTMGL1.hgt.zip' ipdb> l 436 if not os.path.isdir(target_dir): 437 os.makedirs(target_dir) 438 439 url = self.url(format_dict) 440 --> 441 srtm_online = self._urlopen(url) 442 zfh = ZipFile(six.BytesIO(srtm_online.read()), 'r') 443 444 zip_member_path = u'{y}{x}.hgt'.format(**format_dict) 445 member = zfh.getinfo(zip_member_path) 446 with open(target_path, 'wb') as fh: ipdb> u > c:\anaconda3\lib\site-packages\cartopy\io\__init__.py(226)path() 224 else: 225 # we need to download the file --> 226 result_path = self.acquire_resource(target_path, format_dict) 227 228 return result_path ipdb> a self = <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D15240> format_dict = {'config': {'downloaders': {('SRTM', 'SRTM3'): <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D0A1D0>, ('shapefiles', 'gshhs'): <cartopy.io.shapereader.GSHHSShpDownloader object at 0x0000000005CAA0B8>, ('shapefiles', 'natural_earth'): <cartopy.io.shapereader.NEShpDownloader object at 0x0000000005C92278>, ('SRTM', 'SRTM1'): <cartopy.io.srtm.SRTMDownloader object at 0x0000000005D15240>}, 'repo_data_dir': 'C:\\Anaconda3\\lib\\site-packages\\cartopy\\data', 'data_dir': 'C:\\Users\\FL232714\\.local\\share\\cartopy', 'pre_existing_data_dir': ''}, 'resolution': 1, 'y': 'N47', 'x': 'E012'} ipdb> u > c:\anaconda3\lib\site-packages\cartopy\io\srtm.py(149)srtm_fname() 147 return None 148 else: --> 149 return self.downloader.path(params) 150 151 def combined(self, lon_min, lat_min, nx, ny): ipdb> u > c:\anaconda3\lib\site-packages\cartopy\io\srtm.py(179)single_tile() 177 178 def single_tile(self, lon, lat): --> 179 fname = self.srtm_fname(lon, lat) 180 if fname is None: 181 raise ValueError('No srtm tile found for those coordinates.') ipdb> q
import urllib
url = 'http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL1.003/2000.02.11/N47E012.SRTMGL1.hgt.zip'
urllib.request.urlopen(url)
import requests
r = requests.get(url)
r
<Response [401]>
import cartopy.crs as ccrs
from cartopy.io import srtm
import matplotlib.pyplot as plt
from cartopy.io import PostprocessedRasterSource, LocatedImage
from cartopy.io.srtm import SRTM3Source, SRTM1Source
def shade(located_elevations):
"""
Given an array of elevations in a LocatedImage, add a relief (shadows) to
give a realistic 3d appearance.
"""
new_img = srtm.add_shading(located_elevations.image,
azimuth=135, altitude=15)
return LocatedImage(new_img, located_elevations.extent)
def plot(Source, name):
plt.figure()
ax = plt.axes(projection=ccrs.PlateCarree())
# Define a raster source which uses the SRTM data and applies the
# shade function when the data is retrieved.
shaded_srtm = PostprocessedRasterSource(Source(), shade)
# Add the shaded SRTM source to our map with a grayscale colormap.
ax.add_raster(shaded_srtm, cmap='Greys')
# This data is high resolution, so pick a small area which has some
# interesting orography.
ax.set_extent([12, 13, 47, 48])
plt.title(name + " Shaded Relief Map")
gl = ax.gridlines(draw_labels=True)
gl.xlabels_top = False
gl.ylabels_left = False
def main():
plot(SRTM3Source, 'SRTM3')
plot(SRTM1Source, 'SRTM1')
plt.show()
main()
C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py:264: DownloadWarning: Downloading: http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL3.003/2000.02.11/N47E012.SRTMGL3.hgt.zip warnings.warn('Downloading: {}'.format(url), DownloadWarning)
--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) C:\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 305 pass 306 else: --> 307 return printer(obj) 308 # Finally look for special method names 309 method = get_real_method(obj, self.print_method) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig) 226 227 if 'png' in formats: --> 228 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs)) 229 if 'retina' in formats or 'png2x' in formats: 230 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs)) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs) 117 118 bytes_io = BytesIO() --> 119 fig.canvas.print_figure(bytes_io, **kw) 120 data = bytes_io.getvalue() 121 if fmt == 'svg': C:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs) 2178 orientation=orientation, 2179 dryrun=True, -> 2180 **kwargs) 2181 renderer = self.figure._cachedRenderer 2182 bbox_inches = self.figure.get_tightbbox(renderer) C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs) 525 526 def print_png(self, filename_or_obj, *args, **kwargs): --> 527 FigureCanvasAgg.draw(self) 528 renderer = self.get_renderer() 529 original_dpi = renderer.dpi C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self) 472 473 try: --> 474 self.figure.draw(self.renderer) 475 finally: 476 RendererAgg.lock.release() C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer) 1157 dsu.sort(key=itemgetter(0)) 1158 for zorder, a, func, args in dsu: -> 1159 func(*args) 1160 1161 renderer.close_group('figure') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py in draw(self, renderer, inframe) 358 359 return matplotlib.axes.Axes.draw(self, renderer=renderer, --> 360 inframe=inframe) 361 362 def __str__(self): C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe) 2322 2323 for zorder, a in dsu: -> 2324 a.draw(renderer) 2325 2326 renderer.close_group('axes') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\slippy_image_artist.py in draw(self, renderer, *args, **kwargs) 53 located_images = self.raster_source.fetch_raster( 54 ax.projection, extent=[x1, x2, y1, y2], ---> 55 target_resolution=(window_extent.width, window_extent.height)) 56 57 for img, extent in located_images: C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in fetch_raster(self, *args, **kwargs) 432 def fetch_raster(self, *args, **kwargs): 433 fetch_raster = super(PostprocessedRasterSource, self).fetch_raster --> 434 located_imgs = fetch_raster(*args, **kwargs) 435 if located_imgs: 436 located_imgs = [self._post_fetch_fn(img) for img in located_imgs] C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in fetch_raster(self, projection, extent, target_resolution) 403 def fetch_raster(self, projection, extent, target_resolution): 404 return self._source.fetch_raster(projection, extent, --> 405 target_resolution) 406 407 def validate_projection(self, projection): C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in fetch_raster(self, projection, extent, target_resolution) 121 return [] 122 else: --> 123 img, _, extent = self.combined(min_x, min_y, nx, ny) 124 return [LocatedImage(np.flipud(img), extent)] 125 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in combined(self, lon_min, lat_min, nx, ny) 165 try: 166 tile_img, _, _ = self.single_tile(bottom_left_ll[0] + i, --> 167 bottom_left_ll[1] + j) 168 except ValueError: 169 img[y_img_slice, x_img_slice] = 0 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in single_tile(self, lon, lat) 177 178 def single_tile(self, lon, lat): --> 179 fname = self.srtm_fname(lon, lat) 180 if fname is None: 181 raise ValueError('No srtm tile found for those coordinates.') C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in srtm_fname(self, lon, lat) 147 return None 148 else: --> 149 return self.downloader.path(params) 150 151 def combined(self, lon_min, lat_min, nx, ny): C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in path(self, format_dict) 224 else: 225 # we need to download the file --> 226 result_path = self.acquire_resource(target_path, format_dict) 227 228 return result_path C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in acquire_resource(self, target_path, format_dict) 439 url = self.url(format_dict) 440 --> 441 srtm_online = self._urlopen(url) 442 zfh = ZipFile(six.BytesIO(srtm_online.read()), 'r') 443 C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in _urlopen(self, url) 263 """ 264 warnings.warn('Downloading: {}'.format(url), DownloadWarning) --> 265 return urlopen(url) 266 267 @staticmethod C:\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 161 else: 162 opener = _opener --> 163 return opener.open(url, data, timeout) 164 165 def install_opener(opener): C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 502 http_err = 0 503 args = (dict, proto, meth_name) + args --> 504 result = self._call_chain(*args) 505 if result: 506 return result C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_302(self, req, fp, code, msg, headers) 694 fp.close() 695 --> 696 return self.parent.open(new, timeout=req.timeout) 697 698 http_error_301 = http_error_303 = http_error_307 = http_error_302 C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 508 if http_err: 509 args = (dict, 'default', 'http_error_default') + orig_args --> 510 return self._call_chain(*args) 511 512 # XXX probably also want an abstract factory that knows when it makes C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs) 588 class HTTPDefaultErrorHandler(BaseHandler): 589 def http_error_default(self, req, fp, code, msg, hdrs): --> 590 raise HTTPError(req.full_url, code, msg, hdrs, fp) 591 592 class HTTPRedirectHandler(BaseHandler): HTTPError: HTTP Error 401: Unauthorized
<matplotlib.figure.Figure at 0x4542ef0>
C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py:264: DownloadWarning: Downloading: http://e4ftl01.cr.usgs.gov/SRTM/SRTMGL1.003/2000.02.11/N47E012.SRTMGL1.hgt.zip warnings.warn('Downloading: {}'.format(url), DownloadWarning)
--------------------------------------------------------------------------- HTTPError Traceback (most recent call last) C:\Anaconda3\lib\site-packages\IPython\core\formatters.py in __call__(self, obj) 305 pass 306 else: --> 307 return printer(obj) 308 # Finally look for special method names 309 method = get_real_method(obj, self.print_method) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in <lambda>(fig) 226 227 if 'png' in formats: --> 228 png_formatter.for_type(Figure, lambda fig: print_figure(fig, 'png', **kwargs)) 229 if 'retina' in formats or 'png2x' in formats: 230 png_formatter.for_type(Figure, lambda fig: retina_figure(fig, **kwargs)) C:\Anaconda3\lib\site-packages\IPython\core\pylabtools.py in print_figure(fig, fmt, bbox_inches, **kwargs) 117 118 bytes_io = BytesIO() --> 119 fig.canvas.print_figure(bytes_io, **kw) 120 data = bytes_io.getvalue() 121 if fmt == 'svg': C:\Anaconda3\lib\site-packages\matplotlib\backend_bases.py in print_figure(self, filename, dpi, facecolor, edgecolor, orientation, format, **kwargs) 2178 orientation=orientation, 2179 dryrun=True, -> 2180 **kwargs) 2181 renderer = self.figure._cachedRenderer 2182 bbox_inches = self.figure.get_tightbbox(renderer) C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in print_png(self, filename_or_obj, *args, **kwargs) 525 526 def print_png(self, filename_or_obj, *args, **kwargs): --> 527 FigureCanvasAgg.draw(self) 528 renderer = self.get_renderer() 529 original_dpi = renderer.dpi C:\Anaconda3\lib\site-packages\matplotlib\backends\backend_agg.py in draw(self) 472 473 try: --> 474 self.figure.draw(self.renderer) 475 finally: 476 RendererAgg.lock.release() C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\figure.py in draw(self, renderer) 1157 dsu.sort(key=itemgetter(0)) 1158 for zorder, a, func, args in dsu: -> 1159 func(*args) 1160 1161 renderer.close_group('figure') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\geoaxes.py in draw(self, renderer, inframe) 358 359 return matplotlib.axes.Axes.draw(self, renderer=renderer, --> 360 inframe=inframe) 361 362 def __str__(self): C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\matplotlib\axes\_base.py in draw(self, renderer, inframe) 2322 2323 for zorder, a in dsu: -> 2324 a.draw(renderer) 2325 2326 renderer.close_group('axes') C:\Anaconda3\lib\site-packages\matplotlib\artist.py in draw_wrapper(artist, renderer, *args, **kwargs) 59 def draw_wrapper(artist, renderer, *args, **kwargs): 60 before(artist, renderer) ---> 61 draw(artist, renderer, *args, **kwargs) 62 after(artist, renderer) 63 C:\Anaconda3\lib\site-packages\cartopy\mpl\slippy_image_artist.py in draw(self, renderer, *args, **kwargs) 53 located_images = self.raster_source.fetch_raster( 54 ax.projection, extent=[x1, x2, y1, y2], ---> 55 target_resolution=(window_extent.width, window_extent.height)) 56 57 for img, extent in located_images: C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in fetch_raster(self, *args, **kwargs) 432 def fetch_raster(self, *args, **kwargs): 433 fetch_raster = super(PostprocessedRasterSource, self).fetch_raster --> 434 located_imgs = fetch_raster(*args, **kwargs) 435 if located_imgs: 436 located_imgs = [self._post_fetch_fn(img) for img in located_imgs] C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in fetch_raster(self, projection, extent, target_resolution) 403 def fetch_raster(self, projection, extent, target_resolution): 404 return self._source.fetch_raster(projection, extent, --> 405 target_resolution) 406 407 def validate_projection(self, projection): C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in fetch_raster(self, projection, extent, target_resolution) 121 return [] 122 else: --> 123 img, _, extent = self.combined(min_x, min_y, nx, ny) 124 return [LocatedImage(np.flipud(img), extent)] 125 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in combined(self, lon_min, lat_min, nx, ny) 165 try: 166 tile_img, _, _ = self.single_tile(bottom_left_ll[0] + i, --> 167 bottom_left_ll[1] + j) 168 except ValueError: 169 img[y_img_slice, x_img_slice] = 0 C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in single_tile(self, lon, lat) 177 178 def single_tile(self, lon, lat): --> 179 fname = self.srtm_fname(lon, lat) 180 if fname is None: 181 raise ValueError('No srtm tile found for those coordinates.') C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in srtm_fname(self, lon, lat) 147 return None 148 else: --> 149 return self.downloader.path(params) 150 151 def combined(self, lon_min, lat_min, nx, ny): C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in path(self, format_dict) 224 else: 225 # we need to download the file --> 226 result_path = self.acquire_resource(target_path, format_dict) 227 228 return result_path C:\Anaconda3\lib\site-packages\cartopy\io\srtm.py in acquire_resource(self, target_path, format_dict) 439 url = self.url(format_dict) 440 --> 441 srtm_online = self._urlopen(url) 442 zfh = ZipFile(six.BytesIO(srtm_online.read()), 'r') 443 C:\Anaconda3\lib\site-packages\cartopy\io\__init__.py in _urlopen(self, url) 263 """ 264 warnings.warn('Downloading: {}'.format(url), DownloadWarning) --> 265 return urlopen(url) 266 267 @staticmethod C:\Anaconda3\lib\urllib\request.py in urlopen(url, data, timeout, cafile, capath, cadefault, context) 161 else: 162 opener = _opener --> 163 return opener.open(url, data, timeout) 164 165 def install_opener(opener): C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 502 http_err = 0 503 args = (dict, proto, meth_name) + args --> 504 result = self._call_chain(*args) 505 if result: 506 return result C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_302(self, req, fp, code, msg, headers) 694 fp.close() 695 --> 696 return self.parent.open(new, timeout=req.timeout) 697 698 http_error_301 = http_error_303 = http_error_307 = http_error_302 C:\Anaconda3\lib\urllib\request.py in open(self, fullurl, data, timeout) 470 for processor in self.process_response.get(protocol, []): 471 meth = getattr(processor, meth_name) --> 472 response = meth(req, response) 473 474 return response C:\Anaconda3\lib\urllib\request.py in http_response(self, request, response) 580 if not (200 <= code < 300): 581 response = self.parent.error( --> 582 'http', request, response, code, msg, hdrs) 583 584 return response C:\Anaconda3\lib\urllib\request.py in error(self, proto, *args) 508 if http_err: 509 args = (dict, 'default', 'http_error_default') + orig_args --> 510 return self._call_chain(*args) 511 512 # XXX probably also want an abstract factory that knows when it makes C:\Anaconda3\lib\urllib\request.py in _call_chain(self, chain, kind, meth_name, *args) 442 for handler in handlers: 443 func = getattr(handler, meth_name) --> 444 result = func(*args) 445 if result is not None: 446 return result C:\Anaconda3\lib\urllib\request.py in http_error_default(self, req, fp, code, msg, hdrs) 588 class HTTPDefaultErrorHandler(BaseHandler): 589 def http_error_default(self, req, fp, code, msg, hdrs): --> 590 raise HTTPError(req.full_url, code, msg, hdrs, fp) 591 592 class HTTPRedirectHandler(BaseHandler): HTTPError: HTTP Error 401: Unauthorized
<matplotlib.figure.Figure at 0x45b24a8>
Interim status: