<html xmlns:v="urn:schemas-microsoft-com:vml" xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:w="urn:schemas-microsoft-com:office:word" xmlns:m="http://schemas.microsoft.com/office/2004/12/omml" xmlns="http://www.w3.org/TR/REC-html40">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=us-ascii">
<meta name="Generator" content="Microsoft Word 15 (filtered medium)">
<style><!--
/* Font Definitions */
@font-face
        {font-family:"Cambria Math";
        panose-1:2 4 5 3 5 4 6 3 2 4;}
@font-face
        {font-family:Calibri;
        panose-1:2 15 5 2 2 2 4 3 2 4;}
@font-face
        {font-family:Consolas;
        panose-1:2 11 6 9 2 2 4 3 2 4;}
/* Style Definitions */
p.MsoNormal, li.MsoNormal, div.MsoNormal
        {margin:0in;
        font-size:11.0pt;
        font-family:"Calibri",sans-serif;}
span.EmailStyle18
        {mso-style-type:personal-compose;
        font-family:"Calibri",sans-serif;
        color:windowtext;}
.MsoChpDefault
        {mso-style-type:export-only;
        font-size:10.0pt;
        font-family:"Calibri",sans-serif;}
@page WordSection1
        {size:8.5in 11.0in;
        margin:1.0in 1.0in 1.0in 1.0in;}
div.WordSection1
        {page:WordSection1;}
--></style><!--[if gte mso 9]><xml>
<o:shapedefaults v:ext="edit" spidmax="1026" />
</xml><![endif]--><!--[if gte mso 9]><xml>
<o:shapelayout v:ext="edit">
<o:idmap v:ext="edit" data="1" />
</o:shapelayout></xml><![endif]-->
</head>
<body lang="EN-US" link="#0563C1" vlink="#954F72" style="word-wrap:break-word">
<div class="WordSection1">
<p class="MsoNormal">I am trying to run a rastercalculator through a call to its python method and I get the error message core.QgsProcessingException: An error occurred while performing the calculation.  Not a very intuitive message.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">The variable _cutfill_nodata_file used in the code below is a path to a result from a previous geoprocessing call and the file does exist, but the call to rastercalculator  seems to have an issue with that file.  If I replace _cutfill_nodata_file
 with self._elevation_layer.dataProvider().dataSourceUri()}@1 it works.  Not what I want to do, but just wanted to test nothing odd about my expression.  Do that basically adds the same layer to itself so I am doubling the cell values.  I want to add the values
 in the file _cutfill_nodata_file, but when I use that file, I get the error below. I tried using just the layer name and band which is what is used in the GUI raster calculator, but that does not work and I expect it to not as I think it only works if the
 layers are in the layer panel which they are not, they are in a temp folder, so I am calling the method using the file names.<o:p></o:p></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">elevation_30m_cutfill_file = os.path.join(</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">self</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">._temp_dir.name,
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">f</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">{</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">self</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">._elevation_layer.name()}</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">_</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">{</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">self</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">.cutfill_layer.name()}</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">.tif"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">)<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">elevation_30m_cutfill_name = os.path.splitext(os.path.basename(elevation_30m_cutfill_file))[</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">0</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">]<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">expression =
</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">f</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">\"{</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">self</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">._elevation_layer.dataProvider().dataSourceUri()}</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">@1</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">\"</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">
 + </span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">\"{_cutfill_nodata_file}</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">@1</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">\"</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4"><o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">processing.run(<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">           
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">"qgis:rastercalculator"</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">,
<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">            {<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'EXPRESSION'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:expression,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'LAYERS'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:[</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">self</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">._elevation_layer.dataProvider().dataSourceUri()],<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'CELLSIZE'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:</span><span style="font-size:10.5pt;font-family:Consolas;color:#B5CEA8">0</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'EXTENT'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">None</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'CRS'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:</span><span style="font-size:10.5pt;font-family:Consolas;color:#569CD6">None</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">,<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">               
</span><span style="font-size:10.5pt;font-family:Consolas;color:#CE9178">'OUTPUT'</span><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">:elevation_30m_cutfill_file<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">            }<o:p></o:p></span></p>
<p class="MsoNormal" style="line-height:14.25pt;background:#1E1E1E"><span style="font-size:10.5pt;font-family:Consolas;color:#D4D4D4">        )<o:p></o:p></span></p>
<p class="MsoNormal"><o:p> </o:p></p>
<p class="MsoNormal">  File "C:\Users\RDTECLAC\AppData\Roaming\QGIS\QGIS3\profiles\default\python\plugins\site_selection\tools\cutfill\cutfill_dialog.py", line 745, in _calculate_cutfill_elevation_layer<br>
              processing.run(<br>
              File "C:\PROGRA~1/QGIS31~1.16/apps/qgis-ltr/./python/plugins\processing\tools\general.py", line 108, in run<br>
              return Processing.runAlgorithm(algOrName, parameters, onFinish, feedback, context)<br>
              File "C:\PROGRA~1/QGIS31~1.16/apps/qgis-ltr/./python/plugins\processing\core\Processing.py", line 174, in runAlgorithm<br>
              ret, results = execute(alg, parameters, context, feedback, catch_exceptions=False)<br>
              File "C:\PROGRA~1/QGIS31~1.16/apps/qgis-ltr/./python/plugins\processing\gui\AlgorithmExecutor.py", line 71, in execute<br>
              results, ok = alg.run(parameters, context, feedback, {}, False)<br>
             _core.QgsProcessingException: An error occurred while performing the calculation<o:p></o:p></p>
</div>
</body>
</html>