-
Notifications
You must be signed in to change notification settings - Fork 179
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
Improve error message for missing 'bidx' parameter #1031
Comments
It might be pretty hard to surface better error message, It's Sad that this doesn't come from GDAL directly. That's said we can maybe aad a set of from rio_tiler.models import ImageData
import numpy
arr = numpy.ma.zeros((5,266,256), dtype="uint8")
img = ImageData(arr)
img.render()
---------------------------------------------------------------------------
ObjectNullError Traceback (most recent call last)
<ipython-input-5-1ac762dfbb8f> in <cell line: 1>()
----> 1 img.render()
~/Dev/CogeoTiff/rio-tiler/rio_tiler/models.py in render(self, add_mask, img_format, colormap, **kwargs)
705
706 if add_mask:
--> 707 return render(
708 array.data,
709 self.mask, # We use dataset mask for rendering
~/Dev/CogeoTiff/rio-tiler/rio_tiler/utils.py in render(data, mask, img_format, colormap, **creation_options)
606 dst.write(mask.astype(data.dtype), indexes=count + 1)
607
--> 608 return memfile.read()
609
610
~/Dev/venv/py39/lib/python3.9/site-packages/rasterio/io.py in __exit__(self, *args)
166
167 def __exit__(self, *args):
--> 168 self._env.close()
169 self.close()
170
/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py in close(self)
538 def close(self):
539 """Immediately unwind the context stack."""
--> 540 self.__exit__(None, None, None)
541
542
/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py in __exit__(self, *exc_details)
530 # set-up context
531 fixed_ctx = exc_details[1].__context__
--> 532 raise exc_details[1]
533 except BaseException:
534 exc_details[1].__context__ = fixed_ctx
/opt/homebrew/Cellar/python@3.9/3.9.19/Frameworks/Python.framework/Versions/3.9/lib/python3.9/contextlib.py in __exit__(self, *exc_details)
515 assert is_sync
516 try:
--> 517 if cb(*exc_details):
518 suppressed_exc = True
519 pending_raise = False
rasterio/_base.pyx in rasterio._base.DatasetBase.__exit__()
rasterio/_base.pyx in rasterio._base.DatasetBase.close()
rasterio/_io.pyx in rasterio._io.BufferedDatasetWriterBase.stop()
rasterio/_err.pyx in rasterio._err.exc_wrap_pointer()
ObjectNullError: Pointer 'hSrcDS' is NULL in 'GDALCreateCopy'. |
@drnextgis I've update rio-tiler to make the error a bit more verbose 🙏 |
Thank you @vincentsarago! The error message is now slightly clearer, although it's still challenging to pinpoint the exact issue just by looking at it:
That said, having this ticket is good - if anyone encounters the same problem, it could be a useful reference. |
Yeah I'm just a bit worry to go further, I would hope GDAL/Rasterio were raising better error messages |
It appears that for rasters with 3 bands, specifying
bidx
is not mandatory. However, when dealing with rasters that have more than 3 bands, such as the following example:If you query a tile without specifying the
bidx
parameter:titiler
returns an error that is difficult to interpret:This error message does not clearly indicate what went wrong. It would be more helpful if the error explicitly mentioned that the
bidx
parameter must be specified when working with rasters containing more than 3 bands.The text was updated successfully, but these errors were encountered: