mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-11-04 00:04:25 -05:00 
			
		
		
		
	Add square brackets around the saved expression
When saving a raster expression the generated expression didn't contain square brackets around the letters used for band identifiers. Sticking with the NDVI example:
```
("NIR@1" - "Red@1") / ("NIR@1" + "Red@1")
```
becomes
```
(a - b) / (a + b)
```
Due to the way the expression is parsed these would not be interactie parameters for the user to set as the parameters requre square brackets around the layer tags. This change simply updates the string replacement to include the square brackets so you would get instead:
```
([a] - [b]) / ([a] + [b])
```
			
			
This commit is contained in:
		
							parent
							
								
									09ea6bebb4
								
							
						
					
					
						commit
						1312cfe599
					
				@ -188,7 +188,7 @@ class ExpressionWidget(BASE, WIDGET):
 | 
			
		||||
        used = [v for v in self.options.values() if v in exp]
 | 
			
		||||
 | 
			
		||||
        for i, v in enumerate(used):
 | 
			
		||||
            exp = exp.replace(v, chr(97 + i))
 | 
			
		||||
            exp = exp.replace(v, f'[{chr(97 + i)}]')
 | 
			
		||||
 | 
			
		||||
        dlg = AddNewExpressionDialog(exp)
 | 
			
		||||
        dlg.exec_()
 | 
			
		||||
 | 
			
		||||
		Loading…
	
	
			
			x
			
			
		
	
		Reference in New Issue
	
	Block a user