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
7c1fbfa1
Commit
7c1fbfa1
authored
Nov 27, 2017
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix for GeoArray.get_subset().
parent
7cc9d3c0
Pipeline
#1614
passed with stages
in 1 minute and 42 seconds
Changes
4
Pipelines
3
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
18 additions
and
8 deletions
+18
-8
geoarray/__init__.py
geoarray/__init__.py
+2
-2
geoarray/baseclasses.py
geoarray/baseclasses.py
+9
-3
setup.py
setup.py
+1
-1
tests/test_geoarray.py
tests/test_geoarray.py
+6
-2
No files found.
geoarray/__init__.py
View file @
7c1fbfa1
...
...
@@ -12,8 +12,8 @@ from .masks import CloudMask # noqa: E402
__author__
=
"""Daniel Scheffler"""
__email__
=
'danschef@gfz-potsdam.de'
__version__
=
'0.7.
5
'
__versionalias__
=
'v2017112
4
.01'
__version__
=
'0.7.
6
'
__versionalias__
=
'v2017112
7
.01'
__all__
=
[
'GeoArray'
,
'BadDataMask'
,
'NoDataMask'
,
...
...
geoarray/baseclasses.py
View file @
7c1fbfa1
...
...
@@ -1411,12 +1411,14 @@ class GeoArray(object):
def
get_subset
(
self
,
xslice
=
None
,
yslice
=
None
,
zslice
=
None
,
return_GeoArray
=
True
,
reset_bandnames
=
False
):
# type: (slice, slice, slice, bool) -> GeoArray
"""Returns a new insta
t
nce of GeoArray representing a subset of the initial one wit respect to given array position.
"""Returns a new instance of GeoArray representing a subset of the initial one wit respect to given array position.
:param xslice: a slice providing the X-position for the subset in the form slice(xstart, xend, xstep)
:param yslice: a slice providing the Y-position for the subset in the form slice(ystart, yend, ystep)
:param zslice: a slice providing the Z-position for the subset in the form slice(zstart, zend, zstep)
:param return_GeoArray: whether to return an instance of GeoArray (default) or a tuple(np.ndarray, gt, prj)
:param reset_bandnames: whether band names of subset should be copied from source GeoArray or reset to
'B1', 'B2', 'B3', ...
:return:
"""
...
...
@@ -1431,8 +1433,12 @@ class GeoArray(object):
sub_gt
=
(
sub_ulXY
[
0
],
self
.
gt
[
1
],
self
.
gt
[
2
],
sub_ulXY
[
1
],
self
.
gt
[
4
],
self
.
gt
[
5
])
# apply zslice to bandnames and metadata
bNs_out
=
list
(
np
.
array
(
list
(
self
.
bandnames
))[
zslice
])
meta_out
=
None
if
self
.
_metadata
is
None
else
self
.
meta
[
list
(
np
.
array
(
range
(
self
.
bands
))[
zslice
])]
if
zslice
:
bNs_out
=
list
(
np
.
array
(
list
(
self
.
bandnames
))[
zslice
])
meta_out
=
None
if
self
.
_metadata
is
None
else
self
.
meta
[
list
(
np
.
array
(
range
(
self
.
bands
))[
zslice
])]
else
:
bNs_out
=
list
(
self
.
bandnames
)
meta_out
=
self
.
meta
# get output GeoArray and copy some properties from the input GeoArray
sub_gA
=
GeoArray
(
sub_arr
,
sub_gt
,
self
.
prj
,
...
...
setup.py
View file @
7c1fbfa1
...
...
@@ -24,7 +24,7 @@ test_requirements = requirements + ["coverage", "nose", "nose2", "nose-htmloutpu
setup
(
name
=
'geoarray'
,
version
=
'0.7.
5
'
,
version
=
'0.7.
6
'
,
description
=
"Fast Python interface for geodata - either on disk or in memory."
,
long_description
=
readme
+
'
\n\n
'
+
history
,
author
=
"Daniel Scheffler"
,
...
...
tests/test_geoarray.py
View file @
7c1fbfa1
...
...
@@ -451,12 +451,16 @@ class Test_GeoarrayFunctions(unittest.TestCase):
self
.
assertTrue
(
np
.
array_equal
(
tile
,
self
.
testtiff
[
rS
:
rE
+
1
,
cS
:
cE
+
1
]))
def
test_get_subset
(
self
):
# test without reseting band names
# test without reset
t
ing band names
sub_gA
=
self
.
testtiff
.
get_subset
(
xslice
=
slice
(
2
,
5
),
yslice
=
slice
(
None
,
3
),
zslice
=
slice
(
1
,
2
))
self
.
assertIsInstance
(
sub_gA
,
GeoArray
)
self
.
assertTrue
(
list
(
sub_gA
.
bandnames
),
list
(
self
.
testtiff
.
bandnames
)[
1
])
# test with reseting band names
# test without providing zslice
sub_gA
=
self
.
testtiff
.
get_subset
(
xslice
=
slice
(
2
,
5
),
yslice
=
slice
(
None
,
3
))
self
.
assertIsInstance
(
sub_gA
,
GeoArray
)
# test with resetting band names
sub_gA
=
self
.
testtiff
.
get_subset
(
xslice
=
slice
(
2
,
5
),
yslice
=
slice
(
None
,
3
),
zslice
=
slice
(
1
,
2
),
reset_bandnames
=
True
)
self
.
assertTrue
(
list
(
sub_gA
.
bandnames
),
[
'B1'
])
...
...
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