I want to extract ROI of Sentinel 2 images, several of them aren't on my ROI. I have treatment to do afterwards in the same loop; for it to be faster I'd like to pass to another image if the error :
2020-02-12 12:06:10 (WARNING) ExtractROI: Could not extract the ROI as it is out of the input image.
2020-02-12 12:06:10 (FATAL) ExtractROI: itk::ERROR: MultiChannelExtractROI(00000013FC1D5890): Extraction Region not consistent with output image
occurs. I found that Try/Except would apply to my situation but I have no clue how to do it since it's not python error.
I'm extracting my ROI as such, on python / linux :
os.system('otbcli_ExtractROI -in path/to/input -out path/to/output -mode fit -mode.fit.vect path/to/vector')
I tried to do
try:
os.system('otbcli_ExtractROI -in path/to/input -out path/to/output -mode fit -mode.fit.vect path/to/vector')
except itk.Exception:
print('Image not in ROI')
but it doesn't work, do you have solutions for me ?