Skip to content

Commit

Permalink
Add square brackets around the saved expression
Browse files Browse the repository at this point in the history
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])
```
  • Loading branch information
om-henners authored and nyalldawson committed Sep 14, 2020
1 parent 09ea6be commit 1312cfe
Showing 1 changed file with 1 addition and 1 deletion.
Expand Up @@ -188,7 +188,7 @@ def savePredefined(self):
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_()
Expand Down

0 comments on commit 1312cfe

Please sign in to comment.