0

I try to work with GDAL library and receive this error:

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 founded those solutions How to set the GDAL_DATA environment variable to point to the directory containing EPSG csv files?

so I change my working enviroment, the path to GDAL-DATA folder and nothing help.

then, I saw this one: How to fix the enviroment variable GDAL_DATA path set?
and for right now it's working but now I have to define the path to GDAL_DATA folder every time.

import os
import ospybook as pb
from ospybook.vectorplotter import VectorPlotter

#Theese two lines are the new solution from the 2nd link that I want to stop adding at the begining of each code
# os.environ['GDAL_DATA'] = r'C:\Users\royanc\Anaconda3\Library\share\gdal'
# os.environ['proj'] = r'C:\Users\royanc\Anaconda3\Library\share'

os.chdir(r'C:\Users\royanc\Desktop\ospybook\osgeopy-data\global')

# Plot populated places on top of countries from an interactive session.
vp = VectorPlotter(True)
vp.plot('ne_50m_admin_0_countries.shp', fill=False)
vp.plot('ne_50m_populated_places.shp', 'bo')

I'm using pycharm 3.6, conda version 4.7.10, python 3.7 on win 8.1

Roy Ancri
  • 119
  • 2
  • 14

1 Answers1

1

Since you are using PyCharm you could set the environment variable in you Run Configuration

Go to Run -> Edit Configurations and set your GDAL_DATA variable here

how to set gdal data

This still requires you to set up the configuration for each project, however it keeps system specific configurations out of your code.

the_cheff
  • 4,690
  • 3
  • 15
  • 23