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

Fix QgsRasterLayer and QgsRasterBlock as_numpy methods #60277

Merged
merged 1 commit into from
Jan 27, 2025

Conversation

merydian
Copy link
Contributor

@merydian merydian commented Jan 26, 2025

This PR addresses two issues:

  1. QgsRasterLayer.as_numpy(use_masking=True) previously did not return a masked array.
  2. QgsRasterBlock.as_numpy() did not use the correct fill value.

The updates ensure:
QgsRasterLayer.as_numpy(use_masking=True) now returns masked arrays using numpy.ma.stack().
QgsRasterBlock.as_numpy() correctly applies the set noDataValue for filling, defaulting to 0 if no value is set.

Closes #60205.

@github-actions github-actions bot added this to the 3.42.0 milestone Jan 26, 2025
Copy link

github-actions bot commented Jan 26, 2025

🪟 Windows builds

Download Windows builds of this PR for testing.
Debug symbols for this build are available here.
(Built from commit 106e5aa)

🪟 Windows Qt6 builds

Download Windows Qt6 builds of this PR for testing.
(Built from commit 106e5aa)

@rouault rouault assigned rouault and unassigned rouault Jan 27, 2025
@rouault rouault merged commit 2bef21d into qgis:master Jan 27, 2025
38 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[PyQGIS] as_numpy(use_masking=True) doesn't work well
2 participants