【发布时间】:2018-05-03 19:19:29
【问题描述】:
有没有我可以配置和放置所有用户都可以使用的自然地球形状文件的位置?我的气隙系统无法连接到 Internet 下载文件,所以我需要将 cartopy 指向本地的 shapefile 存储并将其配置为在那里查看,而不是在找不到它们时尝试伸手~ /.local/share/cartopy/shapefiles/ 文件结构。由于这个原因,即使是我安装的最简单的测试也失败了。我找到了一些关于如何在该结构中放置 shapefile 的参考资料,因此我可以在其他地方进行模仿。我想也可以将每个用户的 .local/share/cartopy/shapefiles 目录符号链接到一个中心位置,但这似乎是一个杂项。我错过了更好的方法吗?
编辑:(希望这是stackoverflow的方式——我是原始提交者)
好的。我回来了。我下载了 ne_110m_yada_yada shapefile,将它们解压缩并放入我的 .local/share/cartopy/shapefile/natural_earth/culture|physical) 中,因为我在运行此测试程序时在连接的笔记本电脑上找到了它们:
import cartopy
import matplotlib.pyplot as plt
def main():
ax = plt.axes(projection=cartopy.crs.PlateCarree())
ax.add_feature(cartopy.feature.LAND)
ax.add_feature(cartopy.feature.OCEAN)
ax.add_feature(cartopy.feature.COASTLINE)
ax.add_feature(cartopy.feature.BORDERS, linestyle=':')
ax.add_feature(cartopy.feature.LAKES, alpha=0.5)
ax.add_feature(cartopy.feature.RIVERS)
ax.set_extent([-20, 60, -40, 40])
plt.show()
if __name__ == '__main__':
main()
按预期工作。我将文件隐藏在我的 .local 缓存中,并让我的系统管理员破解 cartopy.config 以指向 /data/cartopy/ 我希望它会在 /data/cartopy/shapefiles/natural_earth/culture|physical 中找到压缩数据的位置最终居住。它是否期望那里有压缩文件,或者只有当它试图出去下载它们时? Cartopy 没有在那里找到 zip 文件并试图上网。将数据放入 pre_existing_data_dir 的规则是什么?如果放在 /data/cartopy/ 中,cartopy 会找到 zip 文件并做正确的事情。还是我需要 shapefile/natural_earth 子目录?我只想将它指向 /data/cartopy 并让它找到我停在该层次结构中的任何 shapefile 或栅格数据,无论来源如何。自然地球只是一个测试案例。我不排除我的系统管理员搞砸了,但他非常能干,我可能误导了他。
最初答案中提供的链接和文档很有帮助,但对 cartopy 挑战的我来说还不够。
【问题讨论】:
标签: cartopy