How to fix the enviroment variable GDAL_DATA path set?(如何修复环境变量 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 路径集?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何修复环境变量 GDAL_DATA 路径集?


- ";find_element_by_name(';name';)";和&QOOT;FIND_ELEMENT(BY NAME,';NAME';)";之间有什么区别? 2022-01-01
- 如何使用PYSPARK从Spark获得批次行 2022-01-01
- 我如何卸载 PyTorch? 2022-01-01
- 使用 Cython 将 Python 链接到共享库 2022-01-01
- 我如何透明地重定向一个Python导入? 2022-01-01
- YouTube API v3 返回截断的观看记录 2022-01-01
- 计算测试数量的Python单元测试 2022-01-01
- 检查具有纬度和经度的地理点是否在 shapefile 中 2022-01-01
- 使用公司代理使Python3.x Slack(松弛客户端) 2022-01-01
- CTR 中的 AES 如何用于 Python 和 PyCrypto? 2022-01-01