[gdal-dev] SetNoDataValue on Memory Raster
DeTracey, Brendan
Brendan.DeTracey at dfo-mpo.gc.ca
Thu Feb 12 11:18:39 PST 2015
Hi,
Using the Python bindings, I am having trouble getting a memory raster to respect SetNoDataValue. It works with a GeoTiff(if I close and then reopen it for reading), I presume because everything gets written when the raster is closed. My code:
conc_band = t_ds.GetRasterBand(1)
conc_band.SetNoDataValue(-32768)
thick_band = t_ds.GetRasterBand(2)
thick_band.SetNoDataValue(-32768)
gdal.RasterizeLayer(t_ds, [1], layer, options=['ATTRIBUTE=CONC'])
gdal.RasterizeLayer(t_ds, [2], layer, options=['ATTRIBUTE=THICK'])
#t_ds.FlushCache()
conc = conc_band.ReadAsArray()
thick = thick_band.ReadAsArray()
When I ReadAsArray, I get a 0 instead of -32768. I tried FlushCache (commented out above) but it did not help. How do I force the raster in memory to update before I reaqd it?
Thanks,
Brendan
More information about the gdal-dev
mailing list