[QGIS-Developer] How to Add Custom QGIS Model Programmatically

Ismail Sunni imajimatika at gmail.com
Sat Jun 1 03:46:24 PDT 2019


Hi Nyall,

Not sure if you've seen
> https://github.com/qgis/QGIS-Enhancement-Proposals/issues/140 , but
> that's designed with this use case very much in mind (and supports
> specifying a model file via the command line, no need for registering
> it in advance anywhere).


Wow, this is more or less what I want to do also. In my case, I want to use
QGIS docker image and add a python script to handle the input. I put my
code in https://github.com/ismailsunni/docker-qgis3-model. It's still in
exploration mode, and still not working with dynamically using a model from
the user. Hopefully, it will be done soon (at least at the end of my course
semester :D ). This for my school project actually, but perhaps it can be
useful for other people.

I use a YAML  file to define the input and output since I feel it's not
easy to put the long parameter after the command.

After reading the QEP and another QEP about official docker image [1], so
this Docker image [2] is not yet an official one?

It's mostly done at
>
> https://github.com/nyalldawson/QGIS/commit/631460cd1b8481cb118b7df2afacc5c3df40b3ad
> , but I need some funds to finalise this and get it merged (e.g. it's
> missing unit tests, and needs upgrading to handle the .var style
> initialisation used by QGIS windows executables, and I also suspect
> there'll be some packaging changes required to allow it to be built
> and installed without the QGIS gui/application libraries).


The implementation seems will be easier to use in Windows. Since by using
Docker, Windows user needs to install Docker first, and it's really not
straight forward unless you have Win 10 Pro.

Thanks for sharing Nyall. My search engine did not show the QEP or your
branch to me :)

Best regards

[1] https://github.com/qgis/QGIS-Enhancement-Proposals/issues/142
[2] https://hub.docker.com/r/qgis/qgis/

On Fri, May 31, 2019 at 12:17 AM Nyall Dawson <nyall.dawson at gmail.com>
wrote:

> On Tue, 28 May 2019 at 23:57, Ismail Sunni <imajimatika at gmail.com> wrote:
> >
> > Dear QGIS developers,
> >
> > Currently, I am trying to create a Docker image based on QGIS official
> docker image to run a custom processing model. I am able to run the
> existing processing model by using a python script.
>
> Not sure if you've seen
> https://github.com/qgis/QGIS-Enhancement-Proposals/issues/140 , but
> that's designed with this use case very much in mind (and supports
> specifying a model file via the command line, no need for registering
> it in advance anywhere).
>
> It's mostly done at
>
> https://github.com/nyalldawson/QGIS/commit/631460cd1b8481cb118b7df2afacc5c3df40b3ad
> , but I need some funds to finalise this and get it merged (e.g. it's
> missing unit tests, and needs upgrading to handle the .var style
> initialisation used by QGIS windows executables, and I also suspect
> there'll be some packaging changes required to allow it to be built
> and installed without the QGIS gui/application libraries).
>
> Nyall
>
> >
> > Unfortunately, for a custom model, I need to register the model first
> (similar to adding a new model in QGIS toolbox) before I can use it. I try
> some ways to do it:
> >
> > Trying to find Python API to do it. I couldn't find it (perhaps I missed
> it)
> > Trying to add/copy manually the model file to the model directory.
> Unfortunately, in the container doesn't even have any profile directory.
> > I tried to find the model directory path, but I can't find it from
> QSettings (it returns empty setting with QSettings.allKeys())
> > I tried to manually create the directories based on my machine model
> directory location, but it's not working also.
> >
> > Any suggestions for this problem? A Python API to add/register the model
> would be a perfect solution.
> >
> > Thanks
> >
> > --
> > Ismail Sunni
> > ismailsunni.wordpress.com
> > _______________________________________________
> > QGIS-Developer mailing list
> > QGIS-Developer at lists.osgeo.org
> > List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> > Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
>


-- 
Ismail Sunni
ismailsunni.wordpress.com
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-developer/attachments/20190601/4c5e3629/attachment.html>


More information about the QGIS-Developer mailing list