-
Notifications
You must be signed in to change notification settings - Fork 108
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
Add NPZ #308
Comments
What's the purpose of this? So that you save |
@kylebarron I first thought that the default 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.save("test.npy", arr)
np.savez_compressed("test.npz", data=arr) There is no difference in size for the one saved with BUT I see an advantage of using 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"] This will be less Lines 440 to 442 in 99d0a16
|
In general, I don't think it's a big deal to return the mask as the last band, especially when you have an API like titiler's with the |
ok ok thanks @kylebarron so summary
|
Note that you can also save multiple arrays to an https://numpy.org/doc/stable/reference/generated/numpy.save.html
with open('test.npy', 'wb') as f:
np.save(f, np.array([1, 2]))
np.save(f, np.array([1, 3]))
with open('test.npy', 'rb') as f:
a = np.load(f)
b = np.load(f)
print(a, b)
# [1 2] [1 3] |
This also goes to my point about the |
rio-tiler/rio_tiler/utils.py
Lines 438 to 446 in 99d0a16
ref: https://numpy.org/doc/stable/reference/generated/numpy.savez.html#numpy.savez
The text was updated successfully, but these errors were encountered: