cogeotiff/rio-tiler

cannot merge Alpha (from colormap) and Mask with different type

vincentsarago opened this issue · 1 comments

reported in stac-utils/titiler-pgstac#79

import numpy

mask = numpy.zeros((256,256), dtype="uint8")
alpha = numpy.zeros((256,256), dtype="float32")

numpy.bitwise_and(alpha, mask)
>> TypeError: ufunc 'bitwise_and' not supported for the input types, and the inputs could not be safely coerced to any supported types according to the casting rule ''safe''

numpy.bitwise_and(alpha, self.mask),

mask = numpy.bitwise_and(alpha, mask)

after more 👀

It appears that the bug is in the mosaic methods

return self.tile.data, (~self.tile.mask[0] * 255).astype(self.tile.dtype)

We shouldn't cast the mask to the data dtype