|
39 | 39 | import cartopy.mpl.feature_artist as feature_artist |
40 | 40 | import cartopy.mpl.patch as cpatch |
41 | 41 | from cartopy.mpl.slippy_image_artist import SlippyImageArtist |
| 42 | +from cartopy.io import Downloader |
42 | 43 |
|
43 | 44 |
|
44 | 45 | assert mpl.__version__ >= '3.1', \ |
@@ -988,22 +989,38 @@ def stock_img(self, name='ne_shaded'): |
988 | 989 | """ |
989 | 990 | Add a standard image to the map. |
990 | 991 |
|
991 | | - Currently, the only (and default) option is a downsampled version of |
992 | | - the Natural Earth shaded relief raster. |
| 992 | + Currently, there are 2 options: |
993 | 993 |
|
| 994 | + 1. 'ne_shaded'(default) a downsampled version of the Natural Earth |
| 995 | + shaded relief raster. |
| 996 | + https://github.com/SciTools/cartopy/blob/master/lib/cartopy/data/raster/natural_earth/50-natural-earth-1-downsampled.png |
| 997 | + 2. 'etopo' a downsampled version of global relief model of Earth's |
| 998 | + surface that integrates land topography and ocean bathymetry. This |
| 999 | + option is the same as the etopo from Basemap. |
| 1000 | + https://www.ngdc.noaa.gov/mgg/image/color_etopo1_ice_low.jpg |
994 | 1001 | """ |
| 1002 | + if name not in ['ne_shaded', 'etopo']: |
| 1003 | + raise ValueError('Unknown stock image %r.' % name) |
| 1004 | + |
995 | 1005 | if name == 'ne_shaded': |
996 | 1006 | import os |
997 | 1007 | source_proj = ccrs.PlateCarree() |
998 | 1008 | fname = os.path.join(config["repo_data_dir"], |
999 | 1009 | 'raster', 'natural_earth', |
1000 | 1010 | '50-natural-earth-1-downsampled.png') |
| 1011 | + elif name == 'etopo': |
| 1012 | + import os |
| 1013 | + source_proj = ccrs.PlateCarree() |
1001 | 1014 |
|
1002 | | - return self.imshow(imread(fname), origin='upper', |
| 1015 | + url_template = 'https://www.ngdc.noaa.gov/mgg/image/{name}.jpg' |
| 1016 | + target_path_template = os.path.join(config["data_dir"], |
| 1017 | + 'raster', '{name}.jpg') |
| 1018 | + d = Downloader(url_template, target_path_template) |
| 1019 | + fname = d.path({'name': 'color_etopo1_ice_low'}) |
| 1020 | + |
| 1021 | + return self.imshow(imread(fname), origin='upper', |
1003 | 1022 | transform=source_proj, |
1004 | 1023 | extent=[-180, 180, -90, 90]) |
1005 | | - else: |
1006 | | - raise ValueError('Unknown stock image %r.' % name) |
1007 | 1024 |
|
1008 | 1025 | def background_img(self, name='ne_shaded', resolution='low', extent=None, |
1009 | 1026 | cache=False): |
|
0 commit comments