如何修复环境变量 GDAL_DATA 路径集? [英] How to fix the enviroment variable GDAL_DATA path set?

查看:69
本文介绍了如何修复环境变量 GDAL_DATA 路径集?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我一直在 windows 10 和 Pycharm 的 python 2.7 中使用 gdal,我无法修复环境中的 GDAL_DATA 路径.因为我收到了这条消息:

I have been work with gdal in python 2.7 in windows 10 and Pycharm, and I can't fix the GDAL_DATA path in the environment. Because that I got this message:

错误 4:无法打开 EPSG 支持文件 gcs.csv.尝试将 GDAL_DATA 环境变量设置为指向包含 EPSG csv 文件的目录.

ERROR 4: Unable to open EPSG support file gcs.csv. Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.

我尝试使用命令行:

set GDAL_DATA='c:/Users/User/share/epsg_csv/'

并尝试使用python代码中的函数:

And try to use the function inside the python code:

import os
os.environ["GDAL_DATA"] = 'c:/Users/User/share/epsg_csv/'

有什么建议吗?

推荐答案

由于某种原因,我不理解 GDAL_DATA 变量(就此而言,PROJ_LIB变量)在使用 Anaconda 4.6 安装 GDAL 包时未设置.

For some reason that I do not understand the GDAL_DATA variable (and for that matter also the PROJ_LIB variable) are not set at installation of the GDAL packages with Anaconda 4.6.

要设置这些变量,我会在程序开始时执行以下操作,然后再调用任何地理模块.

To set these variables I do the following at the start of the program before calling any of the geo modules.

import os
os.environ['GDAL_DATA'] = os.environ['CONDA_PREFIX'] + r'Librarysharegdal'
os.environ['PROJ_LIB'] = os.environ['CONDA_PREFIX'] + r'Libraryshare'

关于我的 conda 环境的信息,CONDA_PREFIX 是:

For information for my conda environment the CONDA_PREFIX is:

c:Users<user_name>Ananconda3envs<my_env>

希望这会有所帮助.

这篇关于如何修复环境变量 GDAL_DATA 路径集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆