0

I'd like to know how can I add, in the map, all the shapefile which are in a specific folder, in one shot; using an algorithm of the Graphical Modeler of QGIS (if it exists). I noticed a similar algorithm, but it can only add a single shapefile. I need this function using the graphical modeler and it should be a part of a complex model.

1
  • 1
    Have you tried to give the path to folder as input? Al least GDAL supports that and reports individual shapefiles as layers as you can test with ogrinfo path_to_folder.
    – user30184
    Jan 24, 2021 at 11:58

1 Answer 1

2

There is a QGIS plugin Load Them All. However, it probably won't work in the Graphic Modeler.

But you can use batch processing for loading data. Let's say you have a very simple Model: load shapefiles, create buffer, safe. When you run the model, select Run as Batch Process…:

enter image description here

You can then select which files should be selected: Autofill… / Add Files by Pattern… and add *.shp to load all Shapefiles in the selected folder. There are many other possibilities to define complex patterns which file(s) should be loaded, including QGIS expressions.

Remark: The same for the output: I used an expression like 'C:\\[my_path]\\buffer\\' || @row_number || '.gpkg' to save the outputs named 0.gpkg, 1.gpkg etc. to the same folder. The double backslashes \\ are necessary to mask the single backslash \ (working on Windows, paths might be different on other operating systems).

enter image description here

3
  • Ok, thanks!! It works! Suppose that, there are 10 .shp in a folder and i want to create a buffer only for 1 and the remaining 9 should be only load in the map. All using the Model. Is it possible?
    – Mark
    Jan 30, 2021 at 9:23
  • Yes. First create the buffer for one file, than run a batch process to open the other ones. Define a criteria for the filename that includes all but the file you created the buffer. Or open also this file again - it will probably do no harm, would it?
    – Babel
    Jan 30, 2021 at 9:28
  • Ok. I'm running a batch process and i have a column set with the 1 layer for the buffer, a column set with the 9 layers to load and a column set for the output. It creates 10 buffers of the 1 layer but the 9 layers are not shown in the map. What's wrong?
    – Mark
    Jan 30, 2021 at 12:06

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.