Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
10
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Open sidebar
Daniel Scheffler
geoarray
Commits
1ec5e10c
Commit
1ec5e10c
authored
Aug 09, 2018
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix for broken GeoArray.get_subset() in case GeoArray.is_inmem == True.
parent
8292fce7
Pipeline
#3086
passed with stages
in 1 minute and 24 seconds
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
7 deletions
+14
-7
geoarray/baseclasses.py
geoarray/baseclasses.py
+14
-7
No files found.
geoarray/baseclasses.py
View file @
1ec5e10c
...
...
@@ -1471,6 +1471,9 @@ class GeoArray(object):
yslicing
=
yslice
.
start
is
not
None
or
yslice
.
stop
is
not
None
or
yslice
.
step
is
not
None
# type: bool
zslicing
=
zslice
.
start
is
not
None
or
zslice
.
stop
is
not
None
or
zslice
.
step
is
not
None
# type: bool
# get array subset #
####################
# get sub_arr
if
zslicing
:
# validation
...
...
@@ -1484,25 +1487,26 @@ class GeoArray(object):
if
sub_arr
is
None
:
raise
ValueError
(
'Unable to return an array for the given slice parameters.'
)
# copy GeoArray instance #
##########################
# get deepcopy of self (but without slowly copying the full-size self.arr)
# -> cache self.arr, overwrite with subset, quickly create sub_gA and recreate self.arr
# -> do the same with attributes 'mask_nodata' and 'mask_baddata'
from
.masks
import
NoDataMask
,
BadDataMask
full_arr
=
self
.
arr
self
.
arr
=
sub_arr
full_mask_nodata
=
self
.
_mask_nodata
full_mask_baddata
=
self
.
_mask_baddata
from
.masks
import
NoDataMask
,
BadDataMask
full_mask_nodata
=
None
self
.
arr
=
sub_arr
if
isinstance
(
self
.
_mask_nodata
,
NoDataMask
):
# avoid computing it here by using private
full_mask_nodata
=
self
.
_mask_nodata
self
.
_mask_nodata
=
self
.
_mask_nodata
.
get_subset
(
xslice
=
xslice
,
yslice
=
yslice
)
full_mask_baddata
=
None
if
isinstance
(
self
.
_mask_baddata
,
BadDataMask
):
# avoid computing it here by using private
full_mask_baddata
=
self
.
_mask_baddata
self
.
_mask_baddata
=
self
.
_mask_baddata
.
get_subset
(
xslice
=
xslice
,
yslice
=
yslice
)
sub_gA
=
deepcopy
(
self
)
# do not copy any references, otherwise numpy arrays would be copied as views
self
.
arr
=
full_arr
self
.
_
arr
=
full_arr
if
isinstance
(
self
.
_mask_nodata
,
NoDataMask
):
self
.
_mask_nodata
=
full_mask_nodata
if
isinstance
(
self
.
_mask_baddata
,
BadDataMask
):
...
...
@@ -1511,6 +1515,9 @@ class GeoArray(object):
# numpy array references need to be cleared separately (also called by self._mask_nodata.get_subset() above)
sub_gA
.
deepcopy_array
()
# handle metadata #
###################
# adapt geotransform
sub_ulXY
=
imXY2mapXY
((
xslice
.
start
or
0
,
yslice
.
start
or
0
),
self
.
gt
)
sub_gt
=
(
sub_ulXY
[
0
],
self
.
gt
[
1
],
self
.
gt
[
2
],
sub_ulXY
[
1
],
self
.
gt
[
4
],
self
.
gt
[
5
])
...
...
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