无法加载"gcs.csv"在gdal中归档 [英] unable to load "gcs.csv" file in gdal

查看:278
本文介绍了无法加载"gcs.csv"在gdal中归档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这个问题可能会重复,但是我没有得到答案. 我已经在python ide中编写了流畅的代码.

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"

我已经做到了,但是仍然出现此错误.但是此代码单独运行,但不能在应用程序中运行.此代码来自gdal的gdal2tile模块.我正在使用python 2.7.6和gdal 1.10.0,我无法找出问题所在和所在位置.请提出解决方案的建议.

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.

推荐答案

GDAL需要一个名为GDAL_DATA的环境变量,该变量指向此处 了解详情.

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.

要检查是否设置了GDAL_DATA并且包含gcs.csv,并且可读性强,请使用以下代码片段检查应用程序.这应该在引发错误的代码附近.

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)))


Anaconda/Miniconda用户

使用Anaconda或Miniconda的正确方法是


Anaconda / Miniconda users

The correct way to use either Anaconda or Miniconda is to activate an environment where GDAL is installed. For example, activate the base environment for Anaconda from Windows cmd.exe:

call %LOCALAPPDATA%\Continuum\anaconda3\Scripts\activate.bat base

激活环境会触发设置诸如GDAL_DATA(及其他)之类的环境变量,并经常更改显示环境名称的命令提示符前缀.停用环境后,将不会设置/还原这些环境变量.

Activating an environment triggers environment variables such as GDAL_DATA (and others) to be set, and often changes the command prompt prefix showing the environment name. These environment variables are unset/restored when the environment is deactivated.

conda deactivate

这篇关于无法加载"gcs.csv"在gdal中归档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆