ExtractROI 'mode fit' generates wrong clip when the reference extent exceeds the input raster extent

Description

ExtractROI application generates wrong clip in fit mode (vect or im reference) when the reference exceeds input raster extent.

It's due to the conversion of physical point to index point. Point that is outside input raster extent can be converted into negative index value (cf. otbExtractROI.cxx )

before ExtractRoi after ExtractRoi corrected ExtractRoi

I fixed the problem by replacing negative index with 0 (cf. fix )

Steps to reproduce

create a vector layer that exceeds your raster

use cmd:

otbcli_ExtractROI -in input.tif -mode fit -mode.fit.vect vect.shp -out output.tif

Configuration information

Ubuntu 16.04, OTB 6.6.1, build with iota2 method

Edited by Sébastien Peillet