Hi, Did anyone have this problem? Any solution?
On 30 Mar 2017 5:08 PM, "Idan Miara" <[email protected]> wrote: Hello, I am trying to read a raster using gdal's ReadAsArray() method in python 3.6. I am using the gdal library provided in Qgis' 2.99 weekly release (QGIS-OSGeo4W-2.99.0-9-Setup-x86_64.exe). this sample script: import gdal x = gdal.Open(r'D:/Map Samples/1/DTM/n29w098d5dtm.tif') #valid tif y = x.ReadAsArray() print(y) produces this error: Traceback (most recent call last): File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 16, in swig_import_helper fp, pathname, description = imp.find_module('_gdal_array', [dirname(__file__)]) File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\imp.py", line 296, in find_module raise ImportError(_ERR_MSG.format(name), name=name) ImportError: No module named '_gdal_array' During handling of the above exception, another exception occurred: Traceback (most recent call last): File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\code.py", line 91, in runcode exec(code, self.locals) File "<input>", line 1, in <module> File "<string>", line 3, in <module> File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\site-packages\osgeo\gdal.py", line 1817, in ReadAsArray from . import gdalnumeric File "C:/PROGRA~1/QGIS2~1.99/apps/qgis-dev/./python\qgis\utils.py", line 647, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\site-packages\osgeo\gdalnumeric.py", line 1, in <module> from osgeo.gdal_array import * File "C:/PROGRA~1/QGIS2~1.99/apps/qgis-dev/./python\qgis\utils.py", line 647, in _import mod = _builtin_import(name, globals, locals, fromlist, level) File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 26, in <module> _gdal_array = swig_import_helper() File "C:\PROGRA~1\QGIS2~1.99\apps\Python36\lib\site-packages\osgeo\gdal_array.py", line 18, in swig_import_helper import _gdal_array File "C:/PROGRA~1/QGIS2~1.99/apps/qgis-dev/./python\qgis\utils.py", line 647, in _import mod = _builtin_import(name, globals, locals, fromlist, level) ModuleNotFoundError: No module named '_gdal_array' What can i do to use gdal's readAsArray method in my code? Thank you.
_______________________________________________ Qgis-developer mailing list [email protected] List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
