mardi 4 août 2015

Error when saving 3D array

I'm trying to save a 3D array of data to a file using the following code:

print "Writing results to a file..."
format = "GTiff"
driver = gdal.GetDriverByName(format)

fileName = 'path_to_folder/FLENAME.tif'
NumberOfBands = 46

new_dataset = driver.Create( fileName, 2400, 2400, NumberOfBands,6)
new_dataset = None

for band in range( NumberOfBands ):
    new_dataset.GetRasterBand(band + 1).WriteArray(DATA[band,:,:])

With this I get the error: 'NoneType' object has no attribute 'GetRasterBand'

I tried it without GetRasterband and got 'NoneType' object is not attainable.

Originally tried np.save as an alternative but it was not implemented and was advised to try this method instead. Any help would be appreciated. Thanks.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire