I would like to write a Python script in the QGIS processing framework allowing the download of files from specific addresses.
Instead of starting my script with: vectorLyr = vector
I would like to have something like: vectorLyr = QgsVectorLayer("D:\...\shape_name.shp", "shape_name", "ogr")
In fact it works when I test the algorithm but fails when I want to save the program in the treatment toolbox (script considered not valid).
I can't find any solution.
Here is a simple programm showing a layer
In the first case I will have to select the layer manually:
##vectorLyr = vector
QgsMapLayerRegistry.instance().addMapLayers([vectorLyr,], True)
In this case the selection is automated:
##vectorLyr = QgsVectorLayer("D:\...\shape_name.shp", "shape_name", "ogr")
QgsMapLayerRegistry.instance().addMapLayers([vectorLyr,], True)
I have tried both options. They work fine but the 2d can't be downloaded as a treatment processing script (I have an error message).
My objective is to write a script:
- which can be executed directly from the processing treatment tool box.(ex "Carte_Affectation2" in the picture)
- able to download automatically a layer from a specific address. (I don't want to select it each time i run the sript)
Illustration:
Script involving a manual selection of the layer (##vectorLyr = vector
):
Script involving an automatic selection of the layer (##vectorLyr = QgsVectorLayer("D:\...\shape_name.shp", "shape_name", "ogr")
)