Set processing input default value to layer custom property

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Set processing input default value to layer custom property

Tom Chadwin
I have two inputs to a processing algorithm, one layer, one string. Is it possible to set the default value of the string input to the value of a given custom property of the layer selected for the other input?

Thanks

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Set processing input default value to layer custom property

Ari Jolma-2
I have a small processing model where one of the algorithms is Rasterize
from GDAL. I needed to set the target resolution to be the same as the
one in one of the input rasters to the model.

The problem was thus the same as yours. My solution was to write a very
simple processor, which takes raster as input and outputs its
resolution. I could then hook its input to the raster in the model input
and hook its output to the resolution input of the rasterize algorithm.

My answer is thus that you need to make a model and find or make an
algorithm, which outputs the layer property you need.

Cheers,

Ari


08.04.2017, 16:33, Tom Chadwin kirjoitti:

> I have two inputs to a processing algorithm, one layer, one string. Is it
> possible to set the default value of the string input to the value of a
> given custom property of the layer selected for the other input?
>
> Thanks
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Set-processing-input-default-value-to-layer-custom-property-tp5316416.html
> Sent from the QGIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Set processing input default value to layer custom property

Tom Chadwin
Hi Ari

What a great idea. Thank you. I guess the one downside is that it means the main algorithm will not function on its own, so you have to rely on documentation to inform the user not to try to use it without your preprocessor?

Thanks again

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Set processing input default value to layer custom property

Ari Jolma-2
11.04.2017, 11:50, Tom Chadwin kirjoitti:
> Hi Ari
>
> What a great idea. Thank you. I guess the one downside is that it means the
> main algorithm will not function on its own, so you have to rely on
> documentation to inform the user not to try to use it without your
> preprocessor?

By main algorithm you mean what? For the user the model appears similar
to any algorithm, although it is made of many algorithms (that's the
case for all QGIS processing models). Each work on their own with
correct input. You can study the model here

https://github.com/ajolma/SmartSeaMSPTool/tree/master/processing_models

Ari

>
> Thanks again
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Set-processing-input-default-value-to-layer-custom-property-tp5316416p5316800.html
> Sent from the QGIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Reply | Threaded
Open this post in threaded view
|

Re: Set processing input default value to layer custom property

Tom Chadwin
Yes, I mean that all models are made up of discrete algorithms, and those algorithms will only really work as intended if chained together as in the model. Nevertheless, the algorithms will appear in the Processing toolbox, so users could try to use them in isolation, and have difficulty forming the required inputs. Or do you prevent the individual algorithms appearing in the Processing toolbox?

Thanks for the link - really useful.

Tom
Reply | Threaded
Open this post in threaded view
|

Re: Set processing input default value to layer custom property

Ari Jolma-2
11.04.2017, 14:41, Tom Chadwin kirjoitti:
> Yes, I mean that all models are made up of discrete algorithms, and those
> algorithms will only really work as intended if chained together as in the
> model. Nevertheless, the algorithms will appear in the Processing toolbox,
> so users could try to use them in isolation, and have difficulty forming the
> required inputs. Or do you prevent the individual algorithms appearing in
> the Processing toolbox?

No. In my case the "compute the cell size of a raster" is just not very
useful to use separately.

Ari

>
> Thanks for the link - really useful.
>
> Tom
>
>
>
> -----
> Buy Pie Spy: Adventures in British pastry 2010-11 on Amazon
> --
> View this message in context: http://osgeo-org.1560.x6.nabble.com/Set-processing-input-default-value-to-layer-custom-property-tp5316416p5316829.html
> Sent from the QGIS - Developer mailing list archive at Nabble.com.
> _______________________________________________
> Qgis-developer mailing list
> [hidden email]
> List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
> Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer

_______________________________________________
Qgis-developer mailing list
[hidden email]
List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer
Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer