We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
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
as_numpy(use_masking=True)
I noticed two problems with as_numpy(use_masking=True):
QgsRasterLayer
QgsRasterBlock
Download this sample dataset from the repository: https://github.com/kadyb/adg2024/blob/main/dane/DEM.tif Run the code below:
from qgis.core import QgsRasterLayer import numpy.ma as ma raster = QgsRasterLayer("DEM.tif", "DEM") print(raster.isValid()) #> True print(raster.dataProvider().sourceNoDataValue(1)) #> 9999.0 ## QgsRasterLayer mat = raster.as_numpy(use_masking = True) print(ma.isMaskedArray(mat)) #> False ## QgsRasterBlock block = raster.dataProvider().block(1, raster.extent(), raster.width(), raster.height()) print(block.isValid()) #> True mat = block.as_numpy(use_masking = True) print(ma.isMaskedArray(mat)) #> True print(mat.fill_value) #> 0.0 # should be 9999.0
QGIS 3.40.0, Windows 10
No response
The text was updated successfully, but these errors were encountered:
Gentle ping @merydian.
Sorry, something went wrong.
Successfully merging a pull request may close this issue.
What is the bug or the crash?
I noticed two problems with
as_numpy(use_masking=True)
:QgsRasterLayer
it doesn't return masked array.QgsRasterBlock
it doesn't use the correct fill value (should be 9999.0 in the example below).Steps to reproduce the issue
Download this sample dataset from the repository: https://github.com/kadyb/adg2024/blob/main/dane/DEM.tif
Run the code below:
Versions
QGIS 3.40.0, Windows 10
Supported QGIS version
New profile
Additional context
No response
The text was updated successfully, but these errors were encountered: