Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bc4b1d2

Browse files
committed
update link to download cartopy data
1 parent f5f1823 commit bc4b1d2

File tree

1 file changed

+12
-1
lines changed

1 file changed

+12
-1
lines changed

scripts/projections.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,22 @@
33
# Released under the BSD License
44
# -----------------------------------------------------------------------------
55
import numpy as np
6-
import cartopy.crs
6+
import cartopy
77
import matplotlib as mpl
88
import matplotlib.pyplot as plt
99

1010

11+
CARTOPY_SOURCE_TEMPLATE = 'https://naturalearth.s3.amazonaws.com/{resolution}_{category}/ne_{resolution}_{name}.zip'
12+
13+
14+
# Configures cartopy to download NaturalEarth shapefiles from S3 instead of naciscdn
15+
# Taken from https://github.com/SciTools/cartopy/issues/1325#issuecomment-904343657
16+
target_path_template = cartopy.io.shapereader.NEShpDownloader.default_downloader().target_path_template
17+
downloader = cartopy.io.shapereader.NEShpDownloader(url_template=CARTOPY_SOURCE_TEMPLATE,
18+
target_path_template=target_path_template)
19+
cartopy.config['downloaders'][('shapefiles', 'natural_earth')] = downloader
20+
21+
1122
# Polar plot
1223
# -----------------------------------------------------------------------------
1324
mpl.rc('axes', linewidth=4.0)

0 commit comments

Comments
 (0)