Skip to content

set gdal.UseExceptions so that open_raster throws RuntimeError #208

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/compass/utils/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import compass

gdal.UseExceptions()

WORKFLOW_SCRIPTS_DIR = os.path.dirname(compass.__file__)
OPERA_OPERATION_CONTACT_EMAIL = '[email protected]'
Expand Down Expand Up @@ -351,7 +352,7 @@ def open_raster(filename, band=1):
ds = gdal.Open(filename, gdal.GA_ReadOnly)
arr = ds.GetRasterBand(band).ReadAsArray()
return arr
except AttributeError:
except RuntimeError:
# GDAL reads 1st 2 bytes of ENVI binary to determine file type. If 1st
# bytes of flat binary is that of a jpeg but the binary is not then
# GDAL throws a libjpeg runtime error. Follow specifically tries to
Expand Down