I'm writing a script to compute the intervisibility between two sets of points using the Intervisibility algorithm from the Visibility Analysis plugin which (to my knowledge) is installed by default in QGIS and available in the processing toolbox.
It needs to be standalone because I intend to pipeline and parallelize the process and don't want the interface/overhead of the application. Using the in-application python console to list the available algorithms,
for alg in QgsApplication.processingRegistry().algorithms():
print(f"{alg.id()} --> {alg.displayName()}")
I get the following options at the end of the list.
...
qgis:vectorlayerscatterplot --> Vector layer scatterplot
qgis:voronoipolygons --> Voronoi polygons
visibility:Intervisibility --> Intervisibility network
visibility:Viewshed --> Viewshed
visibility:create_viewpoints --> Create viewpoints
I understand that to use these algorithms in the standalone script I need to add the algorithms provider. I do so using the following code.
import os
import sys
sys.path.append(os.path.abspath('/home/USER/.local/share/QGIS/QGIS3/profiles/default/python/plugins/'))
from qgis.core import QgsApplication
from ViewshedAnalysis.visibility_provider import VisibilityProvider
from qgis.analysis import QgsNativeAlgorithms
qgs = QgsApplication([], False)
qgs.initQgis()
import processing
from processing.core.Processing import Processing
Processing.initialize()
QgsApplication.processingRegistry().addProvider(VisibilityProvider())
QgsApplication.processingRegistry().addProvider(QgsNativeAlgorithms())
However, the same code to list the algorithms now ends with,
...
qgis:vectorlayerscatterplot --> Vector layer scatterplot
qgis:voronoipolygons --> Voronoi polygons
: -->
: -->
: -->
And, calls to visibility:Intervisibility
fail with Algorithm not found
error. What am I missing?