Geographic Information Systems Stack Exchange is a question and answer site for cartographers, geographers and GIS professionals. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Here's the problem shown in Python shell:

In [32]: from osgeo import gdal

In [33]: geotiff = '/Users/calvin/work/luc/proj_public/media/GLO

In [33]: geotiff = '/Users/calvin/work/luc/proj_public/media/GLOBCOVER_L4_200901_200912_V2.3.color.tif'

In [34]: src = gdal.Open(geotiff)

In [35]: band = src.GetRasterBand(1)

In [36]: band
Out[36]: <osgeo.gdal.Band; proxy of <Swig Object of type 'GDALRasterBandShadow *' at 0x10632b8f0> >

In [37]: ar = band.ReadAsArray()
ValueError                                Traceback (most recent call last)
/Users/calvin/work/luc/<ipython-input-37-d7dde170464f> in <module>()
----> 1 ar = band.ReadAsArray()

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/osgeo/gdal.pyc in ReadAsArray(self, xoff, yoff, win_xsize, win_ysize, buf_xsize, buf_ysize, buf_obj)
    893         return gdalnumeric.BandReadAsArray( self, xoff, yoff,
    894                                             win_xsize, win_ysize,
--> 895                                             buf_xsize, buf_ysize, buf_obj )
    897     def WriteArray(self, array, xoff=0, yoff=0):

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/osgeo/gdal_array.pyc in BandReadAsArray(band, xoff, yoff, win_xsize, win_ysize, buf_xsize, buf_ysize, buf_obj)
    225                                     buf_xsize, buf_ysize, datatype )
    226         ar = numpy.fromstring(band_str,dtype=typecode)
--> 227         ar = numpy.reshape(ar, [buf_ysize,buf_xsize])
    229         return ar

/opt/local/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages/numpy/core/fromnumeric.pyc in reshape(a, newshape, order)
    169     except AttributeError:
    170         return _wrapit(a, 'reshape', newshape, order=order)
--> 171     return reshape(newshape, order=order)

ValueError: total size of new array must be unchanged
share|improve this question
Was any solution found? – najuste Sep 21 '12 at 11:00

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.