Geo Django GDAL异常OGR失败 [英] Geo Django GDAL Exception OGR Failure
本文介绍了Geo Django GDAL异常OGR失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在使用geo django并在Windows上运行。我的确在设置中配置了GDAL和OSGEOS。
I'm using geo django and running on windows. I do have GDAL and OSGEOS configured in the settings.
这是我的gdal的settings.py代码。
import os
if os.name == 'nt':
import platform
OSGEO4W = r"C:\OSGeo4W"
if '64' in platform.architecture()[0]:
OSGEO4W += "64"
assert os.path.isdir(OSGEO4W), "Directory does not exist: " + OSGEO4W
os.environ['OSGEO4W_ROOT'] = OSGEO4W
os.environ['GDAL_DATA'] = OSGEO4W + r"\share\gdal"
os.environ['PROJ_LIB'] = OSGEO4W + r"\share\proj"
os.environ['PATH'] = OSGEO4W + r"\bin;" + os.environ['PATH']
我有一个带有点场的模型。
模型:
class Event(models.Model):
user = models.ForeignKey(User, on_delete=models.SET, blank=True)
name = models.CharField(max_length=100)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
location = models.PointField(srid=4326, blank=True)
无论何时我尝试创建一个事件并设置点域值,我收到此错误:
GDAL_ERROR 6: b'Unable to load PROJ.4 library (proj.dll), creation of\nOGRCoordin
ateTransformation failed.'
Error transforming geometry from srid '4326' to srid '3857' (OGR failure.)
此问题似乎是Windows唯一的问题。当我在virtualbox上的ubuntu上运行此应用程序时,一切似乎都正常运行。
This problem seems to be a windows only issue. When I run this application on ubuntu on my virtualbox, everything seems to work fine.
推荐答案
尝试将其添加到设置文件
Try adding this to settings file
os.environ['GDAL_DATA'] = "C:\\OSGeo4W64\\share\\epsg_csv" <- (path to gcs.csv file)
这篇关于Geo Django GDAL异常OGR失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文