[gdal-dev] Failure to fetch scale_factor and other on a subdataset of a L2 SST nc file (from OceanColor)

Joaquim Luis jluis at ualg.pt
Wed May 11 14:56:32 PDT 2016


In GMT we have this chunk of code to read Band metadata

if (GDALGetRasterScale(hBand, &bSuccess) != 1 ||  
GDALGetRasterOffset(hBand, &bSuccess) != 0) {
	Ctrl->band_field_names[nBand].ScaleOffset[0] = GDALGetRasterScale (hBand,  
	Ctrl->band_field_names[nBand].ScaleOffset[1] = GDALGetRasterOffset(hBand,  
else {


and it works fine so far. However, when I use it on a SST L2 file from  
OceanColor (a netCDF4 file) as in


(GMT syntax to access the subdataset), the calls to

GDALGetRasterScale(hBand, &bSuccess)

and friends return no data (bSuccess == 0 and confirmed in a debugger).  
However, if add a temporary

	char **papszMetadataBand = GDALGetMetadata(hBand, NULL);
	int i, nCounterBand = CSLCount(papszMetadataBand);
	for (i = 0; i < nCounterBand; i++)
		fprintf(stderr, "Meta %d\t%s\n", i, papszMetadataBand[i]);

than the band's metadata is printed correctly (same info as that printed  
with gdalinfo).

Question: is this what it looks, a bug?



More information about the gdal-dev mailing list