Julien Demaria reports the following via the mailing list, and this is presumably related. I have reassigned this bug report to Denis who is responsible for this driver. It would be really nice to have this resolved for GDAL 1.4.1.
Hi,
I have found a bug in the computing of the GeoTransform in the function netCDFDataset::SetProjection of the netcdfdataset.cpp file (last version): the resolution was wrong and the origin was the center and not the upper-left corner:
poDS->adfGeoTransform[0] = pdfXCoord[0];
poDS->adfGeoTransform[3] = pdfYCoord[0];
poDS->adfGeoTransform[2] = 0;
poDS->adfGeoTransform[4] = 0;
poDS->adfGeoTransform[1] = (( pdfXCoord[xdim-1] -
pdfXCoord[0] ) /
poDS->nRasterXSize);
poDS->adfGeoTransform[5] = (( pdfYCoord[ydim-1] -
pdfYCoord[0] ) /
poDS->nRasterYSize);
should be corrected with:
poDS->adfGeoTransform[0] = pdfXCoord[0];
poDS->adfGeoTransform[3] = pdfYCoord[0];
poDS->adfGeoTransform[2] = 0;
poDS->adfGeoTransform[4] = 0;
poDS->adfGeoTransform[1] = (( pdfXCoord[xdim-1] -
pdfXCoord[0] ) /
( poDS->nRasterXSize - 1 ));
poDS->adfGeoTransform[5] = (( pdfYCoord[ydim-1] -
pdfYCoord[0] ) /
( poDS->nRasterYSize - 1 ));
poDS->adfGeoTransform[0] = pdfXCoord[0]
- (poDS->adfGeoTransform[1] / 2);
poDS->adfGeoTransform[3] = pdfYCoord[0]
- (poDS->adfGeoTransform[5] / 2);
Maybe there is also the same problem just after this code when trying to retrieve the geolocation from the attributes like "Northernmost_Northing", depending if these attributes define border or center pixel:
adfGeoTransform[0] = dfWE;
adfGeoTransform[1] = (dfEE - dfWE) / poDS->GetRasterXSize();
adfGeoTransform[2] = 0.0;
adfGeoTransform[3] = dfNN;
adfGeoTransform[4] = 0.0;
adfGeoTransform[5] = (dfSN - dfNN) / poDS->GetRasterYSize();
Regards,
Julien