From e0dcc2a62b944d66447a7598a60c8a24bfd81610 Mon Sep 17 00:00:00 2001 From: Guillaume Pasero <guillaume.pasero@c-s.fr> Date: Fri, 13 Jun 2014 14:49:38 +0200 Subject: [PATCH] BUG: Mantis-942: pixel convention consistency between GDAL and OTB --- Code/BasicFilters/otbRasterizeVectorDataFilter.txx | 4 ++-- Code/Common/otbLabelImageToOGRDataSourceFilter.txx | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Code/BasicFilters/otbRasterizeVectorDataFilter.txx b/Code/BasicFilters/otbRasterizeVectorDataFilter.txx index 40a7dc3857..4b417b0537 100644 --- a/Code/BasicFilters/otbRasterizeVectorDataFilter.txx +++ b/Code/BasicFilters/otbRasterizeVectorDataFilter.txx @@ -174,8 +174,8 @@ RasterizeVectorDataFilter<TVectorData, TInputImage, TOutputImage>::GenerateData( InputIndexType bufferIndexOrigin = bufferedRegion.GetIndex(); InputPointType bufferOrigin; this->GetOutput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0]; - geoTransform[3] = bufferOrigin[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetOutput()->GetSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetOutput()->GetSpacing()[1]; geoTransform[1] = this->GetOutput()->GetSpacing()[0]; geoTransform[5] = this->GetOutput()->GetSpacing()[1]; diff --git a/Code/Common/otbLabelImageToOGRDataSourceFilter.txx b/Code/Common/otbLabelImageToOGRDataSourceFilter.txx index 807ff59a8a..a1ad27a208 100644 --- a/Code/Common/otbLabelImageToOGRDataSourceFilter.txx +++ b/Code/Common/otbLabelImageToOGRDataSourceFilter.txx @@ -186,8 +186,8 @@ LabelImageToOGRDataSourceFilter<TInputImage> IndexType bufferIndexOrigin = this->GetInput()->GetBufferedRegion().GetIndex(); OriginType bufferOrigin; this->GetInput()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0]; - geoTransform[3] = bufferOrigin[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInput()->GetSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInput()->GetSpacing()[1]; geoTransform[1] = this->GetInput()->GetSpacing()[0]; geoTransform[5] = this->GetInput()->GetSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters @@ -256,8 +256,8 @@ LabelImageToOGRDataSourceFilter<TInputImage> // the spacing is unchanged, the origin is relative to the buffered region bufferIndexOrigin = this->GetInputMask()->GetBufferedRegion().GetIndex(); this->GetInputMask()->TransformIndexToPhysicalPoint(bufferIndexOrigin, bufferOrigin); - geoTransform[0] = bufferOrigin[0]; - geoTransform[3] = bufferOrigin[1]; + geoTransform[0] = bufferOrigin[0] - 0.5 * this->GetInputMask()->GetSpacing()[0]; + geoTransform[3] = bufferOrigin[1] - 0.5 * this->GetInputMask()->GetSpacing()[1]; geoTransform[1] = this->GetInputMask()->GetSpacing()[0]; geoTransform[5] = this->GetInputMask()->GetSpacing()[1]; // FIXME: Here component 1 and 4 should be replaced by the orientation parameters -- GitLab