I want to use the "Networks" extension on PyQGIS. This is correctly installed on QGIS 3.28 (QGIS installed with OSGeo4W) and works on the application.
Unfortunately, it is impossible to use it on PyQGIS. The error
QgsProcessingException: Error: Algorithm Networks:update_field not found
systematically appears.
For exemple, i want to add a column with this extension (algorythme "update_field").
import sys
import os
import shutil
from qgis.core import *
QgsApplication.setPrefixPath("/usr", True)
qgs = QgsApplication([], False)
qgs.initQgis()
sys.path.extend(['C:/OSGeo4W/apps/qgis-ltr/python/plugins', 'C:/OSGeo4W/apps/qgis-ltr/python/plugins/processing',
'C:/OSGeo4W/apps/qgis-ltr/python', 'C:/OSGeo4W/apps/qgis-ltr/plugins'])
from qgis.analysis import *
import processing
from processing.core.Processing import Processing
from qgis.analysis import QgsNativeAlgorithms
Processing.initialize() # needed to be able to use the functions afterwards
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
path = f"C:/WAMP/www/CALCULATEUR_ITINERAIRE/RESEAU/"
outputs = {}
alg_params = {
'EXISTANT': 'Longueur',#name of the column to add
'FILTRE': '',
'FORMULE': '$length',
'INPUT': path + "data/road.gpkg",
'OUTPUT': path + f'result/final.gpkg',
'PRECISION': 5,
'TAILLE': 15,
'TYPE': 1
}
processing.run('Networks:update_field', alg_params)
The extension is available and can be downloaded here -> https://urlz.fr/pyJH
The "processing.run('Networks:update_field', alg_params)" code is pasted from the QGIS model builder, I don't think I'm wrong with the syntax.
Does anyone have any clues to give me?
sys.path. – Ben W Feb 16 '24 at 04:04