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

NPZ ? #3

Open
vincentsarago opened this issue Dec 3, 2020 · 0 comments
Open

NPZ ? #3

vincentsarago opened this issue Dec 3, 2020 · 0 comments

Comments

@vincentsarago
Copy link

What about Numpy multiple arrays https://numpy.org/doc/stable/reference/generated/numpy.savez_compressed.html

I added it to rio-tiler (ref: cogeotiff/rio-tiler#308). Storing multiple arrays is something I usually do by default (data + mask), but with the .NPY format I usually happen the mask in the data array (quite a hack IMO). With the NPZ format, the arrays can be stored in a separate way

import numpy as np

arr = np.random.randint(0, 255, size=(3, 512, 512), dtype=np.uint8)
mask = np.zeros((512, 512), dtype=np.uint8)

np.savez_compressed("test.npz", data=arr, mask=mask)
arrz = np.load("test.npz")
print(arrz.files)
>> ['data', 'mask']

data, mask = arrz["data"], arrz["mask"]
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