<div dir="ltr"><div dir="ltr"><div>Hi Victor,</div><div><br></div><div>You can do it as Javier said. However, if you really wish to do everything in the modeler, you can do so, but the loops in the modeler are optimized for data already in GRASS and thus it would be sort of clumsy.</div><div><br></div><div>You define your models using a variable, for example %map as I did for my r.in.gdal:</div><div><br></div><div><img src="cid:ii_lr2er6wo1" alt="Screenshot from 2024-01-06 19-32-44.png" width="578" height="449"><br></div><div><br></div><div>Then you can define a loop using the "Add loop/series to model" button (or Model -> Add loop / series). If the maps were already imported, you could automatically loop through them based on a pattern. As there are outside, you would need to write all of them manually (or copy from some list of yours) which is pretty annoying but possible (see the field "Condition" in the example below):</div><div><br></div><div><img src="cid:ii_lr2evaji3" alt="Screenshot from 2024-01-06 19-33-46.png" width="497" height="439"><br></div><div><br></div><div>That's it, just choose all your modules to be included in the loop. However, I would recommend also another way that's easy even if you don't feel Pythonist enough. As you already have your model defined, you could use the "Python editor" tab and you already have your Python script that needs just minimal changes. So if my model consisting of r.in.gdal and r.out.gdal produced this Python script:</div><div><br></div><div>```</div><div>import sys<br>import os<br>import atexit<br><br>from grass.script import parser, run_command<br><br>def cleanup():<br> pass<br><br>def main(options, flags):<br> run_command("r.in.gdal",<br> input="input_raster",<br> output="imported_raster",<br> memory=300,<br> offset=0,<br> num_digits=0)<br><br> run_command("r.out.gdal",<br> input="imported_raster",<br> output="raster_output",<br> format="GTiff",<br> overviews=0)<br><br> return 0<br><br>if __name__ == "__main__":<br> options, flags = parser()<br> atexit.register(cleanup)<br> sys.exit(main(options, flags))</div><div>```</div><div><br></div><div>I would just need to change it to the following. Please note the extra `import glob`, `for` loop, indentation change, and variables used in r.in.gdal[input] and r.out.gdal[output]. Naturally, you could also change the intermediate map names based on the `file_path` variable if you wish so:<br></div><div><br></div><div>```</div><div>import sys<br>import os<br>import atexit<br>import glob<br><br>from grass.script import parser, run_command<br><br>def cleanup():<br> pass<br><br>def main(options, flags):<br> for file_path in glob.glob('your_data_path/*'):<br> run_command("r.in.gdal",<br> input=file_path,<br> output="imported_raster",<br> memory=300,<br> offset=0,<br> num_digits=0)<br><br> run_command("r.out.gdal",<br> input="imported_raster",<br> output=os.path.join("your_output_dir", os.path.basename(file_path)),<br> format="GTiff",<br> overviews=0)<br><br> return 0<br><br>if __name__ == "__main__":<br> options, flags = parser()<br> atexit.register(cleanup)<br> sys.exit(main(options, flags))<br></div><div>```<br></div><div><br></div><div>Cheers.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">so 6. 1. 2024 v 11:17 odesílatel Victor Lundström via grass-user <<a href="mailto:grass-user@lists.osgeo.org">grass-user@lists.osgeo.org</a>> napsal:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div class="msg7612999404380572533">
<div dir="ltr">
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
Hi everyone,<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<br>
</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I'm trying the start getting familiar with the graphical modeler as I have a lot of raster operations that I need to automate. </div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
I have 456 raster layers that I (1) want to interpolate using v.surf.bspline, and then (2) export to six different folders, 76 rasters for each.<br>
<br>
I have designed the workflow in the graphical modeler using just one layer to see that everything works the way that it should, and it does!<br>
However, I can't for the life of me figure out how to set up a loop so that it can iterate through all the remaining layers. I'm trying my best to</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
read the manual, but since all of this is new to me, I can't figure out (1) how to add several raster layers. Whenever I use the "add data to model" I can</div>
<div style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">
<span style="font-family:Aptos,Aptos_EmbeddedFont,Aptos_MSFontService,Calibri,Helvetica,sans-serif;font-size:12pt;color:rgb(0,0,0)">only add one layer from the drop down list. I also don't know if I need two loops, one for interpolation and then
one for the raster export.<br>
<br>
I have attached a screenshot that outlines my model. I hope you'll be able to guide me in the right direction!<br>
<br>
Best,<br>
Victor</span>
</div></div><br></div></blockquote></div></div>