NCPP / ocgis

OpenClimateGIS is a set of geoprocessing and calculation tools for CF-compliant climate datasets.
Other
70 stars 19 forks source link

No module named 'ogr' error GDAL >= 3.2 #522

Open danwild opened 2 years ago

danwild commented 2 years ago

From GDAL v3.2, importing in this way:

 import ogr

fails with error (apparently, this import approach "has been deprecated for 10 years")

Trace:

import ocgis
  File "/opt/conda/lib/python3.9/site-packages/ocgis/__init__.py", line 23, in <module>
    from .spatial.geom_cabinet import GeomCabinet, GeomCabinetIterator, ShpCabinet, ShpCabinetIterator
  File "/opt/conda/lib/python3.9/site-packages/ocgis/spatial/geom_cabinet.py", line 5, in <module>
    import ogr
ModuleNotFoundError: No module named 'ogr'

From what I can see, we only need to change this line in geom_cabinet.py, to be:

from osgeo import ogr

PR to follow.