Quantcast
Channel: Active questions tagged raster-calculator - Geographic Information Systems Stack Exchange
Viewing all articles
Browse latest Browse all 202

All 0s result from raster calculator in python

$
0
0

Raster calculator is not working correctly for a single calculation using a standalone Python script. I am trying to add 1 to a pre-existing raster. It processes, but the resulting tiff file is all 0s. I have used similar code for other rasters and calculations which work, but this one does not.

entries = []Layer1 = QgsRasterLayer('input.tif', "Lyr1")print(Layer1.isValid()) # it is validras = QgsRasterCalculatorEntry()ras.ref = 'lyr1@1'ras.raster = Layer1ras.bandNumber = 1entries.append(ras)calc = QgsRasterCalculator('"lyr1@1"+1', 'output.tif', 'GTiff', \Layer1.extent(), Layer1.width(), Layer1.height(), entries)calc.processCalculation()   

Viewing all articles
Browse latest Browse all 202

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>