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

Reproject fails with error when self.res contains numpy floats #409

Closed
adehecq opened this issue Oct 20, 2023 · 0 comments · Fixed by #410
Closed

Reproject fails with error when self.res contains numpy floats #409

adehecq opened this issue Oct 20, 2023 · 0 comments · Fixed by #410
Labels
bug Something isn't working

Comments

@adehecq
Copy link
Member

adehecq commented Oct 20, 2023

Describe the bug
When running Raster.reproject on an object for which the items in self.res are numpy.float64 (as opposed to float), it fails at this line with "ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()"
This is because the test dst_res == self.res[0] == self.res[1] behaves differently. With float, it returns a single boolean, for np.float64, it returns a tuple of booleans.

To Reproduce
As self.res cannot be set manually, the best way to reproduce (and the way I came across the bug) is to load with downsampling:

import geoutils as gu
rst = gu.Raster(gu.examples.get_path("everest_landsat_b4"))
print(type(rst.res[0]))
# -> float

rst = gu.Raster(gu.examples.get_path("everest_landsat_b4"), downsample=2)
print(type(rst.res[0]))
# -> numpy.float64

rst.reproject(dst_res=(20, 20))
# -> ValueError

Expected behavior
The function should proceed without error.

System (please complete the following information):
Irrelevant

@adehecq adehecq added the bug Something isn't working label Oct 20, 2023
@adehecq adehecq linked a pull request Dec 20, 2023 that will close this issue
adehecq added a commit that referenced this issue Jan 16, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant