diff --git a/Code/IO/otbGDALImageIO.cxx b/Code/IO/otbGDALImageIO.cxx index 966bb071e7084b56f031938a88d3ac3713eaa905..dff5e861b7a731ad276302d27c1df0200c0f1e1d 100644 --- a/Code/IO/otbGDALImageIO.cxx +++ b/Code/IO/otbGDALImageIO.cxx @@ -138,7 +138,7 @@ GDALImageIO::GDALImageIO() // Set default spacing to one m_Spacing[0] = 1.0; m_Spacing[1] = 1.0; - // Set default origin to zero + // Set default origin to half a pixel (centered pixel convention) m_Origin[0] = 0.5; m_Origin[1] = 0.5; @@ -1035,6 +1035,8 @@ void GDALImageIO::InternalReadImageInformation() } } // Geotransforms with a non-null rotation are not supported + // Beware : GDAL origin is at the corner of the top-left pixel + // whereas OTB/ITK origin is at the centre of the top-left pixel m_Origin[0] = VadfGeoTransform[0] + 0.5*m_Spacing[0]; m_Origin[1] = VadfGeoTransform[3] + 0.5*m_Spacing[1]; } @@ -1678,6 +1680,8 @@ void GDALImageIO::InternalWriteImageInformation(const void* buffer) /* -------------------------------------------------------------------- */ itk::VariableLengthVector<double> geoTransform(6); /// Reporting origin and spacing + // Beware : GDAL origin is at the corner of the top-left pixel + // whereas OTB/ITK origin is at the centre of the top-left pixel geoTransform[0] = m_Origin[0] - 0.5*m_Spacing[0]; geoTransform[3] = m_Origin[1] - 0.5*m_Spacing[1]; geoTransform[1] = m_Spacing[0]; diff --git a/Code/IO/otbJPEG2000ImageIO.cxx b/Code/IO/otbJPEG2000ImageIO.cxx index 0542a9c7d2b709963cd1ff3b43f25164e007aae4..c6de7808a3284f1714afa47019f69fd334226c06 100644 --- a/Code/IO/otbJPEG2000ImageIO.cxx +++ b/Code/IO/otbJPEG2000ImageIO.cxx @@ -1274,6 +1274,8 @@ void JPEG2000ImageIO::ReadImageInformation() } } // Geotransforms with a non-null rotation are not supported + // Beware : GDAL origin is at the corner of the top-left pixel + // whereas OTB/ITK origin is at the centre of the top-left pixel m_Origin[0] = geoTransform[0] + 0.5*m_Spacing[0]; m_Origin[1] = geoTransform[3] + 0.5*m_Spacing[1]; }