How to fix the enviroment variable GDAL_DATA path set?

前端 未结 1 469
再見小時候
再見小時候 2021-01-24 22:40

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:

相关标签:
1条回答
  • 2021-01-24 23:13

    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.

    0 讨论(0)
提交回复
热议问题