python - 从 Natural Earth 和 OpenStreetMap for Cartopy 下载数据

标签 python openstreetmap cartopy

我正在尝试使用 cartopy 绘制多张 map ,我想离线使用它们。 Cartopy有一个数据目录,

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'}

所以我相信我可以从 Natural Earth 下载 map 地点。我怎样才能在这个目录中构建这些数据,这样 cartopy 就不会使用互联网来绘图?我如何才能对 OpenStreetMap 数据执行相同的操作?

最佳答案

(仅部分回答)

在 Natural Earth 网站 http://www.naturalearthdata.com/downloads/,您可以找到所有可下载的文件。 例如,此链接提供低分辨率数据:http://www.naturalearthdata.com/downloads/110m-physical-vectors/

该页面上的其中一个数据文件具有以下链接地址: http://www.naturalearthdata.com/http//www.naturalearthdata.com/download/110m/physical/ne_110m_coaSTLine.zip

这段代码将下载该文件(如果它在计算机上不可用):-

import cartopy
fname = cartopy.io.shapereader.natural_earth( \
  resolution='110m', \
  category='physical', \
  name='110m_coastline')

fname 是下载文件的完整路径名。

cartopy无需自行安排下载位置。它已经有默认位置,您可以通过以下方式找到:

cartopy.config['data_dir']   # usually 'C:\\Users\\username\\.local\\share\\cartopy'

您可以查看下载的文件并查看它们在该位置的结构。

下次当您使用 cartopy 函数 cartopy.io.shapereader.natural_earth(使用默认配置)时,它将使用可用的本地文件。

关于python - 从 Natural Earth 和 OpenStreetMap for Cartopy 下载数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/35707514/

相关文章:

python - 如何升级virtualenv以使用新系统python?

3d - 使用开源 3D 引擎从 Openstreetmap 数据渲染 map ?

android - 如何在 React Native 中离线使用谷歌地图

python - 导入Cartopy时ImportError : DLL load failed while importing trace: The specified module could not be found

python - 使用 cartopy 绘制来自 netcdf 的数据并不是在 0 经度处绘制数据

python - 在代码运行之间保留变量的数据

python - Python 中的属性

python - 将句子另存为服务器文件名

java - GeoWebCache 和 osmdroid

linux - 如何在 linux-32 上将 Cartopy 安装到 python-3.5