I am using python 2.7 and have gdal installed. I want to read an entire .jpg image at once and so I used statement
import gdalfrom gdalconst import *driver = gdal.GetDriverByName('JPEG')driver.Register()dataset = gdal.Open('1.jpg', GA_ReadOnly)cols = dataset.RasterXSizerows = dataset.RasterYSizebands = dataset.RasterCountgeotransform = dataset.GetGeoTransform()originX = geotransform[0]originY = geotransform[3]pixelWidth = geotransform[1]pixelHeight = geotransform[5]band = dataset.GetRasterBand(1)data = band.ReadAsArray(0, 0, cols, rows)but I am getting an import error for gdal_array.
ImportError Traceback (most recent call last) in ()----> 1 data = band.ReadAsArray(0, 0, cols, rows)C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal.pyc in ReadAsArray(self, xoff, yoff, win_xsize, win_ysize, buf_xsize, buf_ysize, buf_obj)1174 def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,1175 buf_xsize=None, buf_ysize=None, buf_obj=None):-> 1176 import gdalnumeric1177 1178 return gdalnumeric.BandReadAsArray( self, xoff, yoff,C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdalnumeric.py in ()----> 1 from gdal_array import *2 from numpy import *C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal_array.py in () 24 fp.close() 25 return _mod ---> 26 _gdal_array = swig_import_helper() 27 del swig_import_helper 28 else: C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal_array.py in swig_import_helper() 16 fp, pathname, description = imp.find_module('_gdal_array', [dirname(__file__)]) 17 except ImportError: ---> 18 import _gdal_array 19 return _gdal_array 20 if fp is not None: ImportError: No module named _gdal_arrayPlease tell me what could possible be going wrong. I am new to using GDAL.
أكثر...
import gdalfrom gdalconst import *driver = gdal.GetDriverByName('JPEG')driver.Register()dataset = gdal.Open('1.jpg', GA_ReadOnly)cols = dataset.RasterXSizerows = dataset.RasterYSizebands = dataset.RasterCountgeotransform = dataset.GetGeoTransform()originX = geotransform[0]originY = geotransform[3]pixelWidth = geotransform[1]pixelHeight = geotransform[5]band = dataset.GetRasterBand(1)data = band.ReadAsArray(0, 0, cols, rows)but I am getting an import error for gdal_array.
ImportError Traceback (most recent call last) in ()----> 1 data = band.ReadAsArray(0, 0, cols, rows)C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal.pyc in ReadAsArray(self, xoff, yoff, win_xsize, win_ysize, buf_xsize, buf_ysize, buf_obj)1174 def ReadAsArray(self, xoff=0, yoff=0, win_xsize=None, win_ysize=None,1175 buf_xsize=None, buf_ysize=None, buf_obj=None):-> 1176 import gdalnumeric1177 1178 return gdalnumeric.BandReadAsArray( self, xoff, yoff,C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdalnumeric.py in ()----> 1 from gdal_array import *2 from numpy import *C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal_array.py in () 24 fp.close() 25 return _mod ---> 26 _gdal_array = swig_import_helper() 27 del swig_import_helper 28 else: C:\Users\DELL\Anaconda\lib\site-packages\osgeo\gdal_array.py in swig_import_helper() 16 fp, pathname, description = imp.find_module('_gdal_array', [dirname(__file__)]) 17 except ImportError: ---> 18 import _gdal_array 19 return _gdal_array 20 if fp is not None: ImportError: No module named _gdal_arrayPlease tell me what could possible be going wrong. I am new to using GDAL.
أكثر...