unable to load “gcs.csv” file in gdal

我只是一个虾纸丫 提交于 2020-01-13 06:58:10

问题


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.

  1. Find the folder where gdal data is stored

    \Anaconda2\envs\gdaltest\Library\share\gdal
    
  2. 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

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