-
Notifications
You must be signed in to change notification settings - Fork 416
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
This works around Cartopy <=0.19 on PyPI using an outdate URL for the Natural Earth data. Instead of worrying about caching, just download directly from S3 using Cartopy's own download code.
- Loading branch information
1 parent
ff0a5a5
commit fc31528
Showing
3 changed files
with
36 additions
and
0 deletions.
There are no files selected for viewing
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
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#!/usr/bin/env python | ||
# Copyright (c) 2021 MetPy Developers. | ||
"""Explicitly download needed Cartopy maps.""" | ||
from cartopy.io import config, Downloader | ||
|
||
AWS_TEMPLATE = ('https://naturalearth.s3.amazonaws.com/{resolution}_' | ||
'{category}/ne_{resolution}_{name}.zip') | ||
|
||
|
||
def grab_ne(category, feature, res): | ||
"""Download the correct Natural Earth feature using Cartopy.""" | ||
download = Downloader.from_config(('shapefiles', 'natural_earth')) | ||
download.path({'category': category, 'name': feature, 'resolution': res, 'config': config}) | ||
|
||
|
||
if __name__ == '__main__': | ||
# Need to override the pre-Cartopy 0.20 URL to use S3 | ||
config['downloaders'][('shapefiles', 'natural_earth')].url_template = AWS_TEMPLATE | ||
|
||
for feat in ['admin_0_boundary_lines_land', 'admin_1_states_provinces_lakes']: | ||
for r in ['110m', '50m', '10m']: | ||
grab_ne('cultural', feat, r) | ||
|
||
for feat, r in [('coastline', '10m'), ('coastline', '50m'), ('coastline', '110m'), | ||
('lakes', '10m'), ('lakes', '50m'), | ||
('land', '10m'), ('land', '50m'), ('land', '110m'), | ||
('ocean', '110m'), ('ocean', '50m'), | ||
('rivers_lake_centerlines', '10m'), ('rivers_lake_centerlines', '110m')]: | ||
grab_ne('physical', feat, r) |