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

'outputCrs' is an unknown keyword argument in QgsRasterCalculator #59890

Open
2 tasks done
kadyb opened this issue Dec 13, 2024 · 0 comments
Open
2 tasks done

'outputCrs' is an unknown keyword argument in QgsRasterCalculator #59890

kadyb opened this issue Dec 13, 2024 · 0 comments
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API Rasters Related to general raster layer handling (not specific data formats)

Comments

@kadyb
Copy link

kadyb commented Dec 13, 2024

What is the bug or the crash?

I tried to use QgsRasterCalculator class in PyQGIS on a simple example, but I encountered the following error:

TypeError: 'outputCrs' is an unknown keyword argument

I checked the name of this parameter here and here and it seems to be correct, but for some reason I get this error. If I remove the parameter names, the code works.

Steps to reproduce the issue

The sample data is available for download here: https://github.com/kadyb/adg2024/blob/main/dane/DEM.tif

from qgis.core import QgsRasterLayer, QgsCoordinateTransformContext
from qgis.analysis import QgsRasterCalculator, QgsRasterCalculatorEntry

raster = QgsRasterLayer("DEM.tif", "DEM")
print(raster.isValid())
#> True
print(raster.crs())
#> <QgsCoordinateReferenceSystem: EPSG:2180>

a = QgsRasterCalculatorEntry()
a.raster = raster
a.bandNumber = 1
a.ref = "DEM@1"

calculator = QgsRasterCalculator(
    formulaString = "'DEM@1' * 1",
    outputFile = "output.tif",
    outputFormat = "GTiff",
    outputExtent = raster.extent(),
    outputCrs = raster.crs(),
    nOutputColumns = raster.width(),
    nOutputRows = raster.height(),
    rasterEntries = [a],
    transformContext = QgsCoordinateTransformContext()
)
#> TypeError: 'outputCrs' is an unknown keyword argument

Versions

This applies to versions 3.40.0 and 3.34.6 on Windows 10.

Supported QGIS version

  • I'm running a supported QGIS version according to the roadmap.

New profile

Additional context

No response

@kadyb kadyb added the Bug Either a bug report, or a bug fix. Let's hope for the latter! label Dec 13, 2024
@agiudiceandrea agiudiceandrea added PyQGIS Related to the PyQGIS API Rasters Related to general raster layer handling (not specific data formats) labels Dec 14, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Either a bug report, or a bug fix. Let's hope for the latter! PyQGIS Related to the PyQGIS API Rasters Related to general raster layer handling (not specific data formats)
Projects
None yet
Development

No branches or pull requests

2 participants