问题
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