问题描述
我正在尝试使用Cartopy绘制几张地图,但我想离线使用它们. Cartopy有一个数据目录,
I'm trying to use cartopy to plot several maps and I want to use them offline. Cartopy has a data directory,
import cartopy.config
cartopy.config
{'data_dir': '/home/user/.local/share/cartopy',
'downloaders': {('shapefiles',
'gshhs'): <cartopy.io.shapereader.GSHHSShpDownloader at 0x7f3ee33ee7d0>,
('shapefiles',
'natural_earth'): <cartopy.io.shapereader.NEShpDownloader at 0x7f3ee33ee710>},
'pre_existing_data_dir': '',
'repo_data_dir': '/home/user/bin/virtualenvs/mobi/local/lib/python2.7/site-packages/cartopy/data'}
所以我相信我可以从自然地球网站下载地图.我如何在此目录中构造此数据,以使Cartopy不会使用互联网进行绘制?我该如何对OpenStreetMap数据进行同样的操作?
So I believe that i can download the maps from Natural Earth site. How can I structure this data on this directory so cartopy would not use the internet to plot? And how can I do the same for OpenStreetMap data?
推荐答案
(仅部分回答)
在Natural Earth网站http://www.naturalearthdata.com/downloads/
上,您可以找到所有可下载的文件.例如,此链接提供了低分辨率数据: http://www.naturalearthdata.com /downloads/110m-physical-vectors/
At Natural Earth web site, http://www.naturalearthdata.com/downloads/
, you can find all the downloadable files.For example, this link provides low resolution data: http://www.naturalearthdata.com/downloads/110m-physical-vectors/
该页面上的一个数据文件具有以下链接地址:http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_coastline.zip
One of the data files on that page has this link address: http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_coastline.zip
这段代码将下载该文件(如果该文件在计算机上不可用):-
This piece of code will download that file (if it is not readily available on the computer):-
import cartopy
fname = cartopy.io.shapereader.natural_earth( \
resolution='110m', \
category='physical', \
name='110m_coastline')
fname
是下载文件的完整路径名.
fname
is full pathname of the downloaded file.
您不需要安排Cartopy的下载位置.它已经具有默认位置,您可以通过以下位置找到它:
You dont need to arrange the download location for cartopy. It already has default location that you can find by:
cartopy.config['data_dir'] # usually 'C:\\Users\\username\\.local\\share\\cartopy'
您可以查看下载的文件,并查看该位置的文件结构.
You can check out the files you downloaded and see how they are structured in that location.
下次使用cartopy功能cartopy.io.shapereader.natural_earth
(具有默认配置)时,它将使用本地文件(如果可用).
Next time when you use cartopy function cartopy.io.shapereader.natural_earth
(with default config) it will use the local files if they are available.
这篇关于从Cartopy的Natural Earth和OpenStreetMap下载数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!