Skip to content Skip to sidebar Skip to footer

How To Fix The Enviroment Variable Gdal_data Path Set?

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 ope

Solution 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.

Post a Comment for "How To Fix The Enviroment Variable Gdal_data Path Set?"