Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error in RasterCollection.from_multi_band_raster(Path(gdd_path)) if no band indices or band names are provided #14

Closed
m-i-g-u-e-l opened this issue Nov 23, 2022 · 2 comments

Comments

@m-i-g-u-e-l
Copy link

m-i-g-u-e-l commented Nov 23, 2022

"gdd_path" points to 365 bands geotiff

gdd_scenes = RasterCollection.from_multi_band_raster(
Path(gdd_path))

Traceback (most recent call last):

File "/home//code/eodal_fork/eodal/eodal/core/raster.py", line 521, in from_multi_band_raster
handler.add_band(

File "/home//code/eodal_fork/eodal/eodal/core/raster.py", line 707, in add_band
raise KeyError(f"Cannot add raster band: {e}")

KeyError: "Cannot add raster band: 'Duplicate band names not permitted'"

During handling of the above exception, another exception occurred:

Traceback (most recent call last):

File "/home//code/eodal_fork/venv/lib/python3.10/site-packages/spyder_kernels/py3compat.py", line 356, in compat_exec
exec(code, globals, locals)

File "/home//code/nutzflaechenanalyse/v2_eodal/extract_data.py", line 184, in
gdd_scenes = RasterCollection.from_multi_band_raster(

File "/home//code/eodal_fork/eodal/eodal/core/raster.py", line 531, in from_multi_band_raster
f"Could not add band {band_names_src[band_idx]} "

TypeError: 'NoneType' object is not subscriptable

@m-i-g-u-e-l
Copy link
Author

m-i-g-u-e-l commented Nov 23, 2022

No error for:

gdd_scenes = RasterCollection.from_multi_band_raster(
Path(gdd_path),
band_idxs=[i+1 for i in range(365)],
)

@m-i-g-u-e-l
Copy link
Author

The class description provides the necessary answer:

class RasterCollection(MutableMapping):
"""
Basic class for storing and handling single and multi-band raster
data from which sensor- or application-specific classes inherit.
A RasterDataHandler contains zero to N instances of
~eodal.core.Band. Bands are always indexed using their band
name, therefore the band name must be unique!
...
"""

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant