Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
G
geoarray
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
6
Issues
6
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Daniel Scheffler
geoarray
Commits
932008c2
Commit
932008c2
authored
Aug 22, 2017
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Improved error handling within GeoArray.from_path().
parent
7fd740e0
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
9 additions
and
8 deletions
+9
-8
geoarray/baseclasses.py
geoarray/baseclasses.py
+9
-8
No files found.
geoarray/baseclasses.py
View file @
932008c2
...
...
@@ -819,26 +819,27 @@ class GeoArray(object):
# read subset area from disk
if
bL
==
list
(
range
(
0
,
B
)):
tempArr
=
gdalnumeric
.
LoadFile
(
path
,
cS
,
rS
,
cE
-
cS
+
1
,
rE
-
rS
+
1
)
if
tempArr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
out_arr
=
np
.
swapaxes
(
np
.
swapaxes
(
tempArr
,
0
,
2
),
0
,
1
)
if
B
>
1
else
tempArr
if
out_arr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
else
:
ds
=
gdal
.
Open
(
path
)
if
len
(
bL
)
==
1
:
band
=
ds
.
GetRasterBand
(
bL
[
0
]
+
1
)
out_arr
=
band
.
ReadAsArray
(
cS
,
rS
,
cE
-
cS
+
1
,
rE
-
rS
+
1
)
band
=
None
if
out_arr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
del
band
else
:
out_arr
=
np
.
empty
((
rE
-
rS
+
1
,
cE
-
cS
+
1
,
len
(
bL
)))
for
i
,
bIdx
in
enumerate
(
bL
):
band
=
ds
.
GetRasterBand
(
bIdx
+
1
)
out_arr
[:,
:,
i
]
=
band
.
ReadAsArray
(
cS
,
rS
,
cE
-
cS
+
1
,
rE
-
rS
+
1
)
band
=
None
if
out_arr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
del
band
ds
=
None
if
out_arr
is
None
:
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
del
ds
# only set self.arr if the whole cube has been read (in order to avoid sudden shape changes)
if
out_arr
.
shape
==
self
.
shape
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment