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
8a3b342b
Commit
8a3b342b
authored
Aug 08, 2018
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fixed issue that bandnames are not written to ENVI header by GeoArray.save().
parent
297fa33f
Pipeline
#3070
passed with stages
in 1 minute and 25 seconds
Changes
3
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
16 deletions
+27
-16
.gitlab-ci.yml
.gitlab-ci.yml
+1
-0
geoarray/baseclasses.py
geoarray/baseclasses.py
+25
-15
tests/CI_docker/context/environment_geoarray.yml
tests/CI_docker/context/environment_geoarray.yml
+1
-1
No files found.
.gitlab-ci.yml
View file @
8a3b342b
...
@@ -41,6 +41,7 @@ test_styles:
...
@@ -41,6 +41,7 @@ test_styles:
-
source /root/miniconda3/bin/activate
-
source /root/miniconda3/bin/activate
-
export GDAL_DATA=/root/miniconda3/share/gdal
-
export GDAL_DATA=/root/miniconda3/share/gdal
-
export PYTHONPATH=$PYTHONPATH:/root
# /root <- directory needed later
-
export PYTHONPATH=$PYTHONPATH:/root
# /root <- directory needed later
-
pip install "pycodestyle>=2.0.0,!=2.4.0"
# TODO remove as soon as docker runner is recreated
-
make lint
-
make lint
artifacts
:
artifacts
:
paths
:
paths
:
...
...
geoarray/baseclasses.py
View file @
8a3b342b
...
@@ -159,21 +159,26 @@ class GeoArray(object):
...
@@ -159,21 +159,26 @@ class GeoArray(object):
# type: (list) -> None
# type: (list) -> None
if
list_bandnames
:
if
list_bandnames
:
assert
isinstance
(
list_bandnames
,
list
),
"A list must be given when setting the 'bandnames' attribute. "
\
if
not
isinstance
(
list_bandnames
,
list
):
"Received %s."
%
type
(
list_bandnames
)
raise
TypeError
(
"A list must be given when setting the 'bandnames' attribute. "
assert
len
(
list_bandnames
)
==
self
.
bands
,
\
"Received %s."
%
type
(
list_bandnames
))
'Number of given bandnames does not match number of bands in array.'
if
len
(
list_bandnames
)
!=
self
.
bands
:
assert
len
(
list
(
set
([
type
(
b
)
for
b
in
list_bandnames
])))
==
1
and
type
(
list_bandnames
[
0
]
==
'str'
),
\
raise
ValueError
(
'Number of given bandnames does not match number of bands in array.'
)
"'bandnames must be a set of strings. Got other datetypes in there.'"
if
len
(
list
(
set
([
type
(
b
)
for
b
in
list_bandnames
])))
!=
1
or
not
isinstance
(
list_bandnames
[
0
],
str
):
raise
ValueError
(
"'bandnames must be a set of strings. Got other datatypes in there.'"
)
bN_dict
=
OrderedDict
((
band
,
i
)
for
i
,
band
in
enumerate
(
list_bandnames
))
bN_dict
=
OrderedDict
((
band
,
i
)
for
i
,
band
in
enumerate
(
list_bandnames
))
assert
len
(
bN_dict
)
==
self
.
bands
,
\
'Bands must not have the same name. Received band list: %s'
%
list_bandnames
if
len
(
bN_dict
)
!=
self
.
bands
:
raise
ValueError
(
'Bands must different names. Received band list: %s'
%
list_bandnames
)
self
.
_bandnames
=
bN_dict
self
.
_bandnames
=
bN_dict
# update bandnames in metadata
try
:
if
self
.
_metadata
is
not
None
:
self
.
metadata
.
band_meta
[
'band_names'
]
=
list_bandnames
self
.
metadata
.
band_meta
[
'band_names'
]
=
list_bandnames
except
AttributeError
:
# in case self._metadata is None
pass
else
:
else
:
del
self
.
bandnames
del
self
.
bandnames
...
@@ -893,6 +898,12 @@ class GeoArray(object):
...
@@ -893,6 +898,12 @@ class GeoArray(object):
# write dataset
# write dataset
ds_out
=
driver
.
CreateCopy
(
out_path
,
ds_inmem
,
options
=
creationOptions
if
creationOptions
else
[])
ds_out
=
driver
.
CreateCopy
(
out_path
,
ds_inmem
,
options
=
creationOptions
if
creationOptions
else
[])
# # rows, columns, bands => bands, rows, columns
# out_arr = self.arr if self.ndim == 2 else np.swapaxes(np.swapaxes(self.arr, 0, 2), 1, 2)
# gdalnumeric.SaveArray(out_arr, out_path, format=fmt, prototype=ds_inmem) # expects bands,rows,columns
# ds_out = gdal.Open(out_path)
del
ds_inmem
del
ds_inmem
################
################
...
@@ -909,7 +920,10 @@ class GeoArray(object):
...
@@ -909,7 +920,10 @@ class GeoArray(object):
if
'band_names'
in
envi_metadict
:
if
'band_names'
in
envi_metadict
:
for
bidx
in
range
(
self
.
bands
):
for
bidx
in
range
(
self
.
bands
):
band
=
ds_out
.
GetRasterBand
(
bidx
+
1
)
band
=
ds_out
.
GetRasterBand
(
bidx
+
1
)
band
.
SetDescription
(
self
.
metadata
.
band_meta
[
'band_names'
][
bidx
].
strip
())
bandname
=
self
.
metadata
.
band_meta
[
'band_names'
][
bidx
].
strip
()
band
.
SetDescription
(
bandname
)
assert
band
.
GetDescription
()
==
bandname
del
band
del
band
if
'description'
in
envi_metadict
:
if
'description'
in
envi_metadict
:
...
@@ -939,10 +953,6 @@ class GeoArray(object):
...
@@ -939,10 +953,6 @@ class GeoArray(object):
del
band
del
band
ds_out
.
FlushCache
()
ds_out
.
FlushCache
()
# rows, columns, bands => bands, rows, columns
# out_arr = self.arr if self.ndim == 2 else np.swapaxes(np.swapaxes(self.arr, 0, 2), 1, 2)
# gdalnumeric.SaveArray(out_arr, out_path, format=fmt, prototype=ds) # expects bands,rows,columns
del
ds_out
del
ds_out
else
:
else
:
...
...
tests/CI_docker/context/environment_geoarray.yml
View file @
8a3b342b
...
@@ -33,7 +33,7 @@ dependencies:
...
@@ -33,7 +33,7 @@ dependencies:
-
six
-
six
-
spectral
-
spectral
-
flake8
-
flake8
-
pycodestyle
-
pycodestyle
<2.4.0
# fixes ImportError: module 'pycodestyle' has no attribute 'break_around_binary_operator'
-
pylint
-
pylint
-
pydocstyle
-
pydocstyle
-
nose
-
nose
...
...
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