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

Explicitly pass dtype during dataset read #208

Merged
merged 2 commits into from
Jul 23, 2023
Merged

Conversation

gjoseph92
Copy link
Owner

We weren't asking rasterio for arrays of the output dtype, so we'd just get whatever the native dtype was of the GeoTIFF. If the GeoTIFF was an integer dtype, but specified floating-point scale/offset, then applying the scaling would fail. This basically moves the cast-to-output-dtype before applying scaling, so whatever you pass for dtype= (float64 by default) will actually control it.

Closes #206

@gjoseph92 gjoseph92 merged commit acaa55a into main Jul 23, 2023
1 check passed
@gjoseph92 gjoseph92 deleted the pass-dtype-to-read branch July 23, 2023 15:52
weiji14 added a commit to weiji14/zen3geo that referenced this pull request Sep 21, 2023
The latest stackstac 0.5.0 version installed via readthedocs does sets the dtype on read-in using rasterio, instead of after reading with `np.astype`, see gjoseph92/stackstac#208. Ideally, this should be fixed upstream in rasterio and GDAL by supporting reading of GeoTIFFs into float16 dtype. Alternative is to cast to float32 instead, though it would be a waste of memory if doing 16-bit precision training.
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

Successfully merging this pull request may close these issues.

stackstac 0.4.3 to 0.4.4 creating an issue
1 participant