Geo Django GDAL Exception OGR Failure

左心房为你撑大大i 提交于 2020-02-16 10:40:09

问题


I'm using geo django and running on windows. I do have GDAL and OSGEOS configured in the settings.

Here is my settings.py code for gdal.

   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']

I have a model that has a pointfield. model:

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)

Whenever I try to create an event and set the pointfield value, I get this error:

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

This problem seems to be a windows only issue. When I run this application on ubuntu on my virtualbox, everything seems to work fine.

来源:https://stackoverflow.com/questions/60139673/geo-django-gdal-exception-ogr-failure

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