问题
This question might be repeat but I did not get answer. I have write flowing code in python ide .
out_srs = osr.SpatialReference()
**self.out_srs.ImportFromEPSG(4326)**
It run fine but when i run it from application it cause an error as follows
Note - Error in line enclosed in 2 stars -----
"Unable to load EPSG support gcs.csv file check setting GDAL_DATA environment variable which point to gdal library contains EPSG.csv file"
I have done it but i still get this error. but this code run separately but not in application. This code is from gdal2tile module of gdal. i am using python 2.7.6 and gdal 1.10.0 I am unable to sort out what is the problem and where it is. Please suggest how to solve this.
回答1:
GDAL needs an environment variable named GDAL_DATA
that points to a directory with various data files, including gcs.csv
. Learn more about it here.
To check if GDAL_DATA
is set, and contains gcs.csv
, and if this is readable, use the following snippets to check the application. This should be near the code that raises the error.
import os
import stat
gdal_data = os.environ['GDAL_DATA']
print('is dir: ' + str(os.path.isdir(gdal_data)))
gcs_csv = os.path.join(gdal_data, 'gcs.csv')
print('is file: ' + str(os.path.isfile(gcs_csv)))
st = os.stat(gcs_csv)
print('is readable: ' + str(bool(st.st_mode & stat.S_IRGRP)))
回答2:
I was able to solve this issue by taking the following steps to set the GDAL_DATA variable in windows.
Find the folder where gdal data is stored
\Anaconda2\envs\gdaltest\Library\share\gdal
open windows command prompt and run following command with the location of your gdal data folder.
set GDAL_DATA=....\....\Library\share\gdal
来源:https://stackoverflow.com/questions/26034782/unable-to-load-gcs-csv-file-in-gdal