7

I am attempting my first use of the modeler from the Graphical Modeler from the Processing menu in QGIS (2.18.3). I made a simple model for using meanshift segmentation. It just has a raster input and the algorithm for the segmentation.

I have several small rasters that I want to segment and so I want to run this iteratively through the rasters. I am not sure how that is done, so I am trying to run the model as a batch process. The batch parameters require me to name an output for each line. It seems tedious to have to write out a path and name for each output. I don't know how to simplify this. In ArcGIS' model builder, I add a generic name with an iterator to just number each new file. The iterator in that modeler is %i%. How should I use the process model to iterate through the list? Is batch processing the right way? How do I designate the names for the output without typing each out individually? I'd be fine if the process just referenced back to the raster names.

EDIT after Oto's answer. I don't get that menu from .... I only get a Save window as shown. You can see that I clicked in the .... I right-clicked and left-clicked and didn't get the save options that you show in your answer. enter image description here

2 Answers 2

6

Hit the ... button, set output file name and save like with usual saving single file. This create a basis for the files names. After hittingSave the Autofill settings should appear.

There you can choose fill with values from any parameter or autofill by numbers, which creates suffix to your output name.

enter image description here

4
  • Oto, that looks like it would work, but I don't get that kind of response from the ... and I am not sure how to fix that.
    – shea
    Commented Apr 26, 2017 at 18:44
  • You have to fill the File name and Save, like usual saving files, than the autofiller should appear.
    – Oto Kaláb
    Commented Apr 26, 2017 at 18:49
  • You're welcome :), I edited the answer so now it should be clearer.
    – Oto Kaláb
    Commented Apr 26, 2017 at 18:58
  • 2
    this works but is it possible to add text AFTER original filename? Right now it is: "myText_originalFilename" but I want "original_Filename_myText"
    – M.S.
    Commented Jan 10, 2018 at 10:33
5

In QGIS 3.8 you can do more complicated file naming in the bulk processor using calculate by expression. Rather than hitting the ... you can do the Autofill... drop down and select calculate by expression and in the expression choose the field with your original file and add the text you want before or after the field.
For example this expression adds degradation_ in front of my input file name (landuse_NY) in the input field:

'C:/Users/BP/Desktop/' || 'Degradation_' || @input ||'.tif'

Resulting in degradation_landuse_NY.tif

And this expression uses a regular expression to take the text after the last underscore in the file name and tack it on to degradation.

'C:/Users/BP/Desktop/' || 'Degradation' || regexp_substr( @input ,'(?:.(?!_))+$')||'.tif'

Resulting in Degradation_NY.tif

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.