TransWikia.com

Save processing modeler output layers to project folder/relative path?

Geographic Information Systems Asked by bovsorrr on August 18, 2020

I am building an algorithm in the processing modeler which takes a csv file as input and creates a number of vector layers as output. I would like to automatically save these layers in the same folder as the project file. As I understand, it should be possible by entering the path “./filename.shp”.

I can set the default save path for each layer in the final “Object Sink Parameter-definition” box in the modeler, but can’t get this to work with a relative path.

When setting absolute path, everything works:
C:/Users/Rasmus/Desktop/testfilQgis/målepunkter.shp

When setting only filename (felt.shp), the filename is added to the modelers default output directory path and saved to this path. When running the model on other computers, it will look for the local directory on my machine.

If I use a relative path (./koter.shp) that whole path will be added to the default output directory path (and break since the . folder doesn’t exist).

Only the one folder up path seems to be accepted, but returns a “Failed to create: Permission denied”.

See below image for the suggested save paths based on these inputs:

default save paths as suggested with above inputs

I’ve looked into using the project_folder as suggested here, but the “object sink parameter-definition” box only takes a path, so I’m not sure how to do that.

And setting the save path manually for each layer every time seems like defying the purpose of building a model. Surely, it must be possible to suggest a relative save path?

project > properties > save paths is set to relative (default).

Thanks in advance!

One Answer

First, create the entire process within the modeler, and include the input "File/Folder". Image1

Then open it with the inbuilt Python editor in QGIS, then edit any code with the file path to the name of the input.

In my example, I have defined the folder as "folderlocation", given it a path. This is the only place you will need to change the folder path each time.Image2

You can see the output points to the folder location in the second red box.

Answered by Sanch on August 18, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP