[Qgis-user] PyGQIS output a layer? v3.16

Andrew Hughes ahhughes at gmail.com
Thu Aug 26 06:31:00 PDT 2021


Hi All,

Thanks for your help. I made some progress, in that a downstream script can
call this one and can access the output layer.

The weird thing is, when I run the script from the QGIS Processing panel,
or try and use it within a model. Neither will detect that the script has
any output.

I am declaring the output here:
https://github.com/ahhughes/pyqgisorama/blob/main/CreateArcGISFeatureLayer.py#L115

and I am setting the output value here:
https://github.com/ahhughes/pyqgisorama/blob/main/CreateArcGISFeatureLayer.py#L146

However it doesn't show up as described above, yet the input does showup...
https://github.com/ahhughes/pyqgisorama/blob/main/CreateArcGISFeatureLayer.py#L106

Any help would be appreciated

Thanks in advance
Andrew


On Wed, 25 Aug 2021 at 21:27, Etienne Trimaille <etienne.trimaille at gmail.com>
wrote:

> A QgsProcessingOutputVectorLayer will understand you are returning a
> QgsVectorLayer.
>
> Maybe I'm wrong, but it works well :
>
> https://github.com/3liz/QuickOSM/blob/master/QuickOSM/quick_osm_processing/advanced/open_osm_file.py#L130..L158
>
> Le mer. 25 août 2021 à 11:59, Richard Duivenvoorde <rdmailings at duif.net>
> a écrit :
>
>> On 8/25/21 8:43 AM, Etienne Trimaille wrote:
>> > You can output a QgsVectorLayer :
>> https://qgis.org/api/classQgsProcessingOutputVectorLayer.html <
>> https://qgis.org/api/classQgsProcessingOutputVectorLayer.html>
>> > The sink is not required and you would avoid a loop to insert all
>> features.
>> >
>> > I think you should also return sink ID or layer ID, not the object
>> itself.
>>
>> Hi Etienne,
>>
>> But the code of Andrew would receive features from a ArcGis feature
>> server.
>> How would you instruct QgsProcessingOutputVectorLayer to use that
>> provider?
>> QgsProcessing::SourceType shows (to me) only general types?
>>
>> Or is there some way to use it as a wrapper around a real layer?
>>
>> Regards,
>>
>> Richard Duivenvoorde
>>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.osgeo.org/pipermail/qgis-user/attachments/20210826/e9a38eb9/attachment.html>


More information about the Qgis-user mailing list