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

ENH: Update minimize dtype for int64 & int8 support #139

Closed
snowman2 opened this issue Mar 4, 2023 · 0 comments · Fixed by #159
Closed

ENH: Update minimize dtype for int64 & int8 support #139

snowman2 opened this issue Mar 4, 2023 · 0 comments · Fixed by #159

Comments

@snowman2
Copy link
Member

snowman2 commented Mar 4, 2023

def _minimize_dtype(dtype: numpy.dtype, fill: float) -> numpy.dtype:
"""
If int64, convert to float64:
https://github.com/OSGeo/gdal/issues/3325
Attempt to convert to float32 if fill is NaN and dtype is integer.
"""
if numpy.issubdtype(dtype, numpy.integer):
if dtype.name == "int8":
# GDAL/rasterio doesn't support int8
dtype = numpy.dtype("int16")
if dtype.name == "int64":
# GDAL/rasterio doesn't support int64
dtype = numpy.dtype("float64")

Related:

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 a pull request may close this issue.

1 participant