How to fix the enviroment variable GDAL_DATA path set?

泪湿孤枕 提交于 2019-12-11 13:58:22

问题


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:

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.

I try to use command line:

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

And try to use the function inside the python code:

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

Any suggestion?


回答1:


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'

For information for my conda environment the CONDA_PREFIX is:

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

Hope this helps.



来源:https://stackoverflow.com/questions/45883445/how-to-fix-the-enviroment-variable-gdal-data-path-set

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!