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
7b1ca393
Commit
7b1ca393
authored
Aug 08, 2018
by
Daniel Scheffler
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Bugfix for not updating GeoArray.metadata.bands within GeoArray.get_subset().
parent
8a3b342b
Pipeline
#3071
failed with stages
in 1 minute and 21 seconds
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
17 additions
and
8 deletions
+17
-8
geoarray/baseclasses.py
geoarray/baseclasses.py
+1
-5
geoarray/metadata.py
geoarray/metadata.py
+16
-3
No files found.
geoarray/baseclasses.py
View file @
7b1ca393
...
...
@@ -1487,11 +1487,7 @@ class GeoArray(object):
# apply zslice to bandnames and metadata
if
zslicing
:
bNs_out
=
list
(
np
.
array
(
list
(
self
.
bandnames
))[
zslice
])
_meta_out
=
deepcopy
(
self
.
meta
)
if
self
.
_metadata
:
for
k
,
v
in
_meta_out
.
band_meta
.
items
():
_meta_out
.
band_meta
[
k
]
=
list
(
np
.
array
(
v
)[
zslice
])
_meta_out
=
self
.
metadata
.
get_band_subset
(
bandslice
=
zslice
)
else
:
bNs_out
=
list
(
self
.
bandnames
)
_meta_out
=
self
.
meta
...
...
geoarray/metadata.py
View file @
7b1ca393
...
...
@@ -2,8 +2,10 @@
import
os
from
pprint
import
pformat
from
copy
import
deepcopy
from
geopandas
import
GeoDataFrame
,
GeoSeries
import
numpy
as
np
try
:
from
osgeo
import
gdal
except
ImportError
:
...
...
@@ -31,7 +33,7 @@ class GDAL_Metadata(object):
self
.
bands
=
nbands
self
.
filePath
=
filePath
self
.
format
=
''
self
.
f
ileF
ormat
=
''
if
filePath
:
self
.
read_from_file
(
filePath
)
...
...
@@ -140,13 +142,13 @@ class GDAL_Metadata(object):
raise
Exception
(
'Error reading file: '
+
gdal
.
GetLastErrorMsg
())
self
.
bands
=
ds
.
RasterCount
self
.
format
=
ds
.
GetDriver
().
GetDescription
()
self
.
f
ileF
ormat
=
ds
.
GetDriver
().
GetDescription
()
###############
# ENVI format #
###############
if
self
.
format
==
'ENVI'
:
if
self
.
f
ileF
ormat
==
'ENVI'
:
metadict
=
ds
.
GetMetadata
(
'ENVI'
)
for
k
,
v
in
metadict
.
items
():
...
...
@@ -201,3 +203,14 @@ class GDAL_Metadata(object):
def
to_ENVI_metadict
(
self
):
return
dict
(
zip
(
self
.
all_meta
.
keys
(),
[
self
.
_convert_param_to_ENVI_str
(
i
)
for
i
in
self
.
all_meta
.
values
()]))
def
get_band_subset
(
self
,
bandslice
=
None
):
bandslice
=
bandslice
or
slice
(
None
)
meta_sub
=
deepcopy
(
self
)
for
k
,
v
in
meta_sub
.
band_meta
.
items
():
meta_sub
.
band_meta
[
k
]
=
list
(
np
.
array
(
v
)[
bandslice
])
meta_sub
.
bands
=
len
(
list
(
range
(
*
bandslice
.
indices
(
bandslice
.
stop
))))
return
meta_sub
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