cartopy.io.shapereader.GSHHSShpDownloader#
- class cartopy.io.shapereader.GSHHSShpDownloader(url_template='https://www.ngdc.noaa.gov/mgg/shorelines/data/gshhs/latest/gshhg-shp-2.3.7.zip', target_path_template=None, pre_downloaded_path_template='')[源代码]#
专注
cartopy.io.Downloader
下载压缩后的GSHHS形状文件并将它们提取到定义的位置。使用时应传递的键
format_dict
是scale
(单个字符指示分辨率)和level
(指示特征类型的数字)。- FORMAT_KEYS = ('config', 'scale', 'level')#
中应提供的最低密钥
format_dict
论据path
,url
,target_path
,pre_downloaded_path
和acquire_resource
方法.
- acquire_resource(target_path, format_dict)[源代码]#
下载压缩文件并提取中列出的文件
zip_file_contents()
到达目标路径。备注
由于一些GSHSS数据可在Cartopy存储库中使用,因此如果“l”或“c”的比例存在,则不会下载它们
cartopy.config['repo_data_dir']
目录.
- static default_downloader()[源代码]#
返回GSHHSShpDownloader实例,该实例期望(并在必要时下载和安装)Cartopy安装的数据目录中的Shapfiles。
通常,用户不需要调用此静态方法。
要查找GSHHSShpDownloader的路径模板:
>>> gshhs_dnldr = GSHHSShpDownloader.default_downloader() >>> print(gshhs_dnldr.target_path_template) {config[data_dir]}/shapefiles/gshhs/{scale}/GSHHS_{scale}_L{level}.shp
- static from_config(specification, config_dict=None)#
的
from_config
静态方法实现从配置字典获取Downloader(子)类实例的逻辑。- 参数:
specification -- 应该是可迭代的,因为它将以相反的顺序进行迭代,以找到最适合此规范的下载器实例。 一个示例规范是
('shapefiles', 'natural_earth')
用于自然地球形状文件。config_dict (optional) -- 通常将其保留为“无”以使用默认值
cartopy.config
“下载者”词典。
示例
>>> from cartopy.io import Downloader >>> >>> dnldr = Downloader('https://example.com/{name}', './{name}.txt') >>> config = {('level_1', 'level_2'): dnldr} >>> d1 = Downloader.from_config(('level_1', 'level_2', 'level_3'), ... config_dict=config) >>> print(d1.url_template) https://example.com/{name} >>> print(d1.url({'name': 'item_name'})) https://example.com/item_name
- path(format_dict)#
返回此资源所代表的磁盘上文件的路径。
如果文件不存在于
pre_downloaded_path()
然后它会检查它是否存在于target_path()
,否则资源将通过acquire_resouce()
从url()
到target_path()
.通常,这是大多数应用程序都会调用的方法,允许新下载器的实现者专业化
acquire_resource()
.- 参数:
format_dict -- 用于替换某些模板变量的字典。子类应记录其中至少需要哪些键
FORMAT_KEYS
类属性。
- pre_downloaded_path(format_dict)#
此资源所代表的文件在磁盘上的路径,如果它不存在,则不会对此路径采取进一步操作,并且所有进一步处理都将使用
target_path()
而不是.- 参数:
format_dict -- 用于替换某些模板变量的字典。子类应记录其中至少需要哪些键
FORMAT_KEYS
类属性。
- target_path(format_dict)#
此资源所代表的文件在磁盘上的路径必须存在或可由当前用户写。此方法不会检查这些条件中的任何一个。
- 参数:
format_dict -- 用于替换某些模板变量的字典。子类应记录其中至少需要哪些键
FORMAT_KEYS
类属性。
- url(format_dict)#
此资源代表的完整URL。
- 参数:
format_dict -- 用于替换某些模板变量的字典。子类应记录其中至少需要哪些键
FORMAT_KEYS
类属性。