[Gdal-dev] netCDF driver GeoTransform bug
Julien Demaria
dem at acri-st.fr
Fri Mar 30 06:16:22 EDT 2007
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
More information about the Gdal-dev
mailing list