[Qgis-user] QGIS Batch / raster calculator : Set par of expressions based on input layer names
celati Laurent
laurent.celati at gmail.com
Sun Jan 25 07:19:51 PST 2026
Dear all,
I work ith QGIS 3.40. Using Landsat 5 satellite, I need to calculate
several indices (vegetation, water, etc.), including the NDVI.
This isn't difficult, but since it's a time series, I have hundreds of
images from which I want to generate these same indices. Until now, I've
been generating these indices using the raster calculator in batch mode.
However, this isn't optimized because I still have to manually edit/adapt
the input filename for each NDVI expression/formula.
Regarding the 'input layers' parameter, it's not too complicated since I've
stored all my Landsat images in the same location/folder. For your
information, these are multi-band Landsat image files in GeoTIFF format
(one TIFF file consists of 8 bands). Regarding the input layers, I select
them by selecting all the files in the input folder.
The complexity is greater with the expression parameter.
Here's an example of NDVI for an image:
(("LT05_L2SP_197029_19920101_20200915_02_T1_SR_MERGE_CLIP_BBOX at 4" *
0.0000275 - 0.2)
-
("LT05_L2SP_197029_19920101_20200915_02_T1_SR_MERGE_CLIP_BBOX at 3" *
0.0000275 - 0.2))
/
(("LT05_L2SP_197029_19920101_20200915_02_T1_SR_MERGE_CLIP_BBOX at 4" *
0.0000275 - 0.2)
+
("LT05_L2SP_197029_19920101_20200915_02_T1_SR_MERGE_CLIP_BBOX at 3" *
0.0000275 - 0.2))
where "LT05_L2SP_197029_19920101_20200915_02_T1_SR_MERGE_CLIP_BBOX" is the
part that is supposed to vary from one image/iteration to another. The rest
is always the same (invariable/fixed). This includes the band number (@3 or
@4). How can I ensure that the variable part of the input name is
defined/determined based on the value set in the first parameter, 'input
layers'? Finally, for the last parameter, 'calculated', the idea would be
to define it by the concatenation of a fixed path part + the variable
filename, which would be defined by 'variable input layer name' + ''_ndvi'.
[image: image.png]
Thanks so much for your help.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260125/9ff6f013/attachment-0001.htm>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image.png
Type: image/png
Size: 45256 bytes
Desc: not available
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20260125/9ff6f013/attachment-0001.png>
More information about the QGIS-User
mailing list