Geo Django GDAL:无法打开EPSG支持文件gcs.csv

问题描述 投票:1回答:1

我最近安装了一个干净的窗口。我通过以下方式安装了OSGeo4W:https://trac.osgeo.org/osgeo4w/我通过下载pip wheel GDAL-2.3.2-cp36-cp36m-win_amd64.whl安装了GDAL。我还将django settings.py配置为:

if os.name == 'nt':
    import platform
    import sys

    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']
    GDAL_LIBRARY_PATH = sys.path[6] + r'\osgeo\gdal203.dll'

此配置在我以前的机器上运行,但是当尝试使用Point字段编辑django模型时,会出现此错误:

GDAL_ERROR 4: b'Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.'
Error transforming geometry from srid '4326' to srid '3857' (OGR failure.)
GDAL_ERROR 4: b'Unable to open EPSG support file gcs.csv.  Try setting the GDAL_DATA environment variable to point to the directory containing EPSG csv files.'
Internal Server Error: /admin/event/event/31/change/

我遵循的配置与之前的设置相同。同一台机器,但是新的操作系统,所以我有点脚。如何配置GDAL_DATA env变量?我尝试了这个建议:

https://stackoverflow.com/a/52597276/9469766

设置GDAL:

GDAL_DATA= OSGEO4W + r'\share\gdal'

GDAL_DATA= OSGEO4W + r'\share\epsg_csv'

但是两者仍然产生相同的异常。

django gdal geodjango ogr osgeo
1个回答
0
投票
也许是一些具有更好解决方案的解决方案,但是在应用了许多修复程序之后,我能够找到在Pycharm中WSL和Remote debug对我有用的唯一解决方案。我已公开要点,您可以尝试设置。GeoDjango Configurations
© www.soinside.com 2019 - 2024. All rights reserved.