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

查看:622
本文介绍了如何修复环境变量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变量也未设置)在安装GDAL时未设置带有Anaconda 4.6的软件包.

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'\Library\share\gdal'
os.environ['PROJ_LIB'] = os.environ['CONDA_PREFIX'] + r'\Library\share'

有关我的conda环境的信息,CONDA_PREFIX为:

For information for my conda environment the CONDA_PREFIX is:

c:\Users\<user_name>\Ananconda3\envs\<my_env>

希望这会有所帮助.

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

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