diff --git a/Code/Common/otbVectorDataExtractROI.txx b/Code/Common/otbVectorDataExtractROI.txx
index a140d5501add040c612d1781110eeca3530d443f..267eea0446919e791ec1f2c24a3e3697faa56800 100644
--- a/Code/Common/otbVectorDataExtractROI.txx
+++ b/Code/Common/otbVectorDataExtractROI.txx
@@ -385,6 +385,8 @@ VectorDataExtractROI<TVectorData>
       y = static_cast<double>(it.Value()[1]);
       index[0] = x;
       index[1] = y;
+      maxId[0] = x;
+      maxId[1] = y;
 
       ++it;
       while (it != vertexlist->End())
@@ -397,7 +399,7 @@ VectorDataExtractROI<TVectorData>
             {
               index[0] = x;
             }
-          if ( y < index[1] )
+          if ( y > index[1] )
             {
               index[1] = y;
             }
@@ -406,7 +408,7 @@ VectorDataExtractROI<TVectorData>
             {
               maxId[0] = x;
             }
-          if ( y > maxId[1] )
+          if ( y < maxId[1] )
             {
               maxId[1] = y;
             }