python3安装FileGDB读写驱动

python3安装FileGDB读写驱动

环境

  • 系统:win10x64
  • python:3.6.5x64

安装步骤

  1. 安装gdal: GDAL‑2.4.1‑cp36‑cp36m‑win_amd64.whl

    pip install GDAL-2.4.1-cp36-cp36m-win_amd64.whl
    
  2. 安装FileGDBAPI.dll:下载地址

    拷贝FileGDBAPI.dll至C:\Program Files\Python36\Lib\site-packages\osgeo目录,安装目录与python安装目录一致

    注意: GDAL 3.x 版本还需要把gdalplugins\disabled中的ogr_FileGDB.dll移动到gdalplugins目录

  3. 测试,已成功加载FileGDB:

    C:\WINDOWS\system32>ogrinfo --formats|findstr "GDB"
      FileGDB -vector- (rw+): ESRI FileGDB
      OpenFileGDB -vector- (rov): ESRI FileGDB
    
  4. ipython测试,可以看到gdb_driver为空,目前为止还是不能使用(GDAL 3.x 版本不需要此步骤)

    >ipython
    Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: from osgeo import ogr
    
    In [2]: gdb_driver=ogr.GetDriverByName("FileGDB")
    
    In [3]: gdb_driver
    
    In [4]:
    
  5. 修改osgeo/__init__.py文件:注释15行,取消注释17行(GDAL 3.x 版本不需要此步骤)

    # __init__ for osgeo package.
    
    # unofficial Windows binaries: set GDAL environment variables if necessary
    import os
    
    try:
        _here = os.path.dirname(__file__)
        if _here not in os.environ['PATH']:
            os.environ['PATH'] = _here + ';' + os.environ['PATH']
        if 'GDAL_DATA' not in os.environ:
            os.environ['GDAL_DATA'] = os.path.join(_here, 'data', 'gdal')
        if 'PROJ_LIB' not in os.environ:
            os.environ['PROJ_LIB'] = os.path.join(_here, 'data', 'proj')
        if 'GDAL_DRIVER_PATH' not in os.environ:
            #pass
            # uncomment the next line to enable plugins
            os.environ['GDAL_DRIVER_PATH'] = os.path.join(_here, 'gdalplugins')
    except Exception:
        pass
    
    del os
    
  6. 再次测试,成功!

    >ipython
    Python 3.6.5 (v3.6.5:f59c0932b4, Mar 28 2018, 17:00:18) [MSC v.1900 64 bit (AMD64)]
    Type 'copyright', 'credits' or 'license' for more information
    IPython 6.4.0 -- An enhanced Interactive Python. Type '?' for help.
    
    In [1]: from osgeo import ogr
    
    In [2]: gdb_driver=ogr.GetDriverByName("FileGDB")
    
    In [3]: gdb_driver
    Out[3]: <osgeo.ogr.Driver; proxy of <Swig Object of type 'OGRDriverShadow *' at 0x00000277407BBC60> >
    
    In [4]:
    
  • 1
    点赞
  • 4
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 5
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 5
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

llc的足迹

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值