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

ValueError for pixel values greater than than 256 ** 3 #16

Open
planemad opened this issue Feb 27, 2018 · 2 comments
Open

ValueError for pixel values greater than than 256 ** 3 #16

planemad opened this issue Feb 27, 2018 · 2 comments

Comments

@planemad
Copy link

While processing a tif with very large no data value, i get this error:

ValueError: Data of 3.4028234663852886e+38 larger than 256 ** 3

A little unexpected since there is no documentation of this limitation.

@dnomadb
Copy link
Contributor

dnomadb commented Feb 27, 2018

It's implicit within the value range of possible output. The maximum value that can be represented by 3 position base 256 is:

256 ** 3 = 16777216

3.4028234663852886e+38 is the max/min value of float32, and probably is a nodata value.

There is no way to encode this very large absolute value within the smaller above range. In addition, there isn't any concept of transparent (yet) in this kind of encoding, and no clear path forward.

In order to handle this, you should:

  • Decide on a "fill" pixel value for these nodata areas -- probably 0
  • Set these pixels to the desired value

That said -- thanks for the heads up on documentation. Some docstrings have been written in the code, I should generate some basic api docs on those.

@tomass
Copy link

tomass commented Sep 27, 2018

Workaround: you can automatically change nodata values to some other value, for example 0 or base value.
To do that, in encoders.py function data_to_rgb, just before first statement of data = data.astype(np.float64) add this line:
data[data < 0] = 0
This changes all negative values to 0.

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

3 participants