That is because the PNG driver does not support Create() Method. Compare the two outputs:
% gdalinfo --format png % gdalinfo --format gtiff > -------Original Message------- > From: Jared Rubin <[email protected]> > Subject: [gdal-dev] core dumping on PNG RGB creation > Sent: Feb 02 '09 19:35 > > I am unable to generate a RGB png image from the python swig interface. > The following code does work if I change the driver to BMP. Is there > something odd about the PNG driver? > Thanks > > > import osgeo.gdal as gdal > import numpy > buf = (numpy.random.rand(100*100*3)*255).round() % 255 > buf = buf.reshape(100,100,3) > driver = gdal.GetDriverByName('PNG') > ds = driver.Create('tmp.png',100,100,3) > ds.GetRasterBand(1).WriteArray(buf[:,:,0]) > ds.GetRasterBand(2).WriteArray(buf[:,:,1]) > ds.GetRasterBand(3).WriteArray(buf[:,:,2]) > > > > _______________________________________________ > gdal-dev mailing list > [email protected] > http://lists.osgeo.org/mailman/listinfo/gdal-dev > _______________________________________________ gdal-dev mailing list [email protected] http://lists.osgeo.org/mailman/listinfo/gdal-dev
