As far as I can tell this occurs because the matrix raster doesn't have the attribute (property) dtype. Something must have changed, but I managed to get it going by using the numpy lib rather than Numeric.
Traceback (most recent call last):
File "test.py", line 9, in <module>
File "/usr/lib/python2.5/site-packages/gdal.py", line 796, in WriteArray
File "usr/lib/python2.5/site-packages/osgeo/gdal_array.py", line 154, in BandWriteArray
The code that worked for me looks like this:
One can also explicitly state the matrix's data type by adding the dtype attribute:
from osgeo import osr, gdal
format = "GTiff"
driver = gdal.GetDriverByName( format )
dst_ds = driver.Create("out.tif", 512, 512, 1, gdal.GDT_Byte )
raster = numpy.zeros( (512, 512) )
raster = numpy.zeros( (512, 512), dtype = numpy.uint8)