Raise IOError when file not found
This commit is contained in:
parent
4f8cb4b421
commit
a2297e8441
@ -8,6 +8,7 @@
|
|||||||
#
|
#
|
||||||
# TODO details
|
# TODO details
|
||||||
|
|
||||||
|
from pathlib import Path
|
||||||
import numpy as np
|
import numpy as np
|
||||||
import gdal
|
import gdal
|
||||||
|
|
||||||
@ -41,7 +42,12 @@ def write(fname, X):
|
|||||||
dst_ds.FlushCache()
|
dst_ds.FlushCache()
|
||||||
|
|
||||||
def read(fname):
|
def read(fname):
|
||||||
gdl_data = gdal.Open(str(fname))
|
pname = Path(fname)
|
||||||
|
|
||||||
|
if not pname.exists():
|
||||||
|
raise IOError('File not found: {}'.format(pname))
|
||||||
|
|
||||||
|
gdl_data = gdal.Open(pname.as_posix())
|
||||||
|
|
||||||
if gdl_data.RasterCount == 1:
|
if gdl_data.RasterCount == 1:
|
||||||
return gdl_data.ReadAsArray()
|
return gdl_data.ReadAsArray()
|
||||||
|
Loading…
Reference in New Issue
Block a user