DigitalGlobe / gbdxtools

(Deprecated) Python SDK for using GBDX
MIT License
74 stars 57 forks source link

Better error message when trying to pansharpen a single pan band (e.g., Worldview-01) #559

Closed matthewhanson closed 5 years ago

matthewhanson commented 5 years ago

GBDX Username

matthew@developmentseed.org

GBDX Account Tier

Working on project for World Bank on their account, think it's probably GBDX Enterprise.

GBDXTools Version

[ 0.16.0 ]

Python Version

Environment

Using docker, with geolambda image and gbdxtools installed.

Description

When saving a GeoTiff of a pan-sharpened image for Worldview-1 tiles a cryptic error message is returned. An error is fine, pan-sharpening a single panchromatic band does not make sense, there are no other bands to pan-sharpen.

Expected behavior:

gbdxtools should throw a more descriptive error indicating that pan-sharpening is not supported for this data.

Actual behavior:

The error is "Index out of bounds 1", full stack trace:

Traceback (most recent call last):
  File "/usr/local/lib/python3.6/site-packages/satgbdx/gbdx.py", line 177, in fetch
    tif = img.geotiff(path=tmp_fout1, proj='EPSG:4326', spec=spec)
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/images/meta.py", line 312, in geotiff
    return to_geotiff(self, **kwargs)
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/rda/io.py", line 66, in to_geotiff
    dra_aoi_bands = dra_aoi[arr._rgb_bands,...]
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/images/rda_image.py", line 131, in __getitem__
    im = super(RDAImage, self).__getitem__(geometry)
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/images/meta.py", line 526, in __getitem__
    return self[arg0, :, :]
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/images/rda_image.py", line 131, in __getitem__
    im = super(RDAImage, self).__getitem__(geometry)
  File "/usr/local/lib/python3.6/site-packages/gbdxtools/images/meta.py", line 550, in __getitem__
    result = super(GeoDaskImage, self).__getitem__(geometry)
  File "/usr/local/lib/python3.6/site-packages/dask/array/core.py", line 1234, in __getitem__
    index2 = normalize_index(index, self.shape)
  File "/usr/local/lib/python3.6/site-packages/dask/array/slicing.py", line 791, in normalize_index
    check_index(i, d)
  File "/usr/local/lib/python3.6/site-packages/dask/array/slicing.py", line 849, in check_index
    raise IndexError("Index out of bounds %s" % dimension)
IndexError: Index out of bounds 1

Example

image = CatalogImage("102001002BA13500", pansharpen=True)
filename = image.geotiff(path='test.tif')
chelm commented 5 years ago

Well shoot yeah i'd say this is pretty ugly way to say do dont this. Will work on it.

chelm commented 5 years ago

I thought this sounded odd. I am unable to reproduce this with the latest gbdxtools. Please try upgrading and if it still happens, reopen the issue.