@@ -275,10 +275,12 @@ def records(self):
275275"""
276276
277277
278- def natural_earth (resolution = '110m' , category = 'physical' , name = 'coastline' ):
278+ def natural_earth (resolution = '110m' , category = 'physical' ,
279+ name = 'coastline' , version = None ):
279280 """
280281 Return the path to the requested natural earth shapefile,
281- downloading and unzipping if necessary.
282+ downloading and unzipping if necessary. If version is not specified,
283+ the latest available version will be downloaded.
282284
283285 To identify valid components for this function, either browse
284286 NaturalEarthData.com, or if you know what you are looking for, go to
@@ -299,10 +301,11 @@ def natural_earth(resolution='110m', category='physical', name='coastline'):
299301 # get hold of the Downloader (typically a NEShpDownloader instance)
300302 # which we can then simply call its path method to get the appropriate
301303 # shapefile (it will download if necessary)
304+ _version_string = "" if version is None else "{version}/"
302305 ne_downloader = Downloader .from_config (('shapefiles' , 'natural_earth' ,
303- resolution , category , name ))
304- format_dict = {'config' : config , 'category' : category ,
305- 'name ' : name , 'resolution ' : resolution }
306+ resolution , category , name ))
307+ format_dict = {'config' : config , 'category' : category , 'name' : name ,
308+ 'resolution ' : resolution , 'version ' : _version_string }
306309 return ne_downloader .path (format_dict )
307310
308311
@@ -321,7 +324,7 @@ class NEShpDownloader(Downloader):
321324 # Define the NaturalEarth URL template. Shapefiles are hosted on AWS since
322325 # 2021: https://github.com/nvkelso/natural-earth-vector/issues/445
323326 _NE_URL_TEMPLATE = ('https://naturalearth.s3.amazonaws.com/'
324- '{resolution}_{category}/ne_{resolution}_{name}.zip' )
327+ '{version}{ resolution}_{category}/ne_{resolution}_{name}.zip' )
325328
326329 def __init__ (self ,
327330 url_template = _NE_URL_TEMPLATE ,
@@ -386,7 +389,7 @@ def default_downloader():
386389 ne_{resolution}_{name}.shp
387390
388391 """
389- default_spec = ('shapefiles' , 'natural_earth' , '{category}' ,
392+ default_spec = ('shapefiles' , 'natural_earth' , '{category}' , '{version}' ,
390393 'ne_{resolution}_{name}.shp' )
391394 ne_path_template = str (
392395 Path ('{config[data_dir]}' ).joinpath (* default_spec ))
0 commit comments