I have a script below which creates variable buffers based on a field "ALT" and the coordinates of many points "X" and "Y"), and dissolves the results. It was written in QGIS 2.X, however I need to migrate this to run using QGIS 3.X.
QgsGeometryAnalyzer is retired as of QGIS 3.X, what 3.X PyQGIS class is the replacement class for QgsGeometryAnalyzer?
##VariableBuffer=name
##Input_Folder=folder
##Coordinate_Reference_System=crs
##Output_shapefile=output vector
import sys, os
from qgis.core import *
from qgis.utils import iface
from qgis.analysis import QgsGeometryAnalyzer
import processing
from osgeo import ogr
txt = Input_Folder
TXTlist = []
BuffList = []
for path, subdirs, files in os.walk(txt):
for name in files:
nametext = os.path.join(path, name)
if nametext.lower() [-3:] == "txt":
TXTlist.append(nametext)
Outdir = txt + "\shp\"
if not os.path.exists(Outdir):
os.makedirs(Outdir)
for txt in TXTlist:
txtname = os.path.basename(txt)[:-4]
Outputshp = Outdir + txtname + ".shp"
Buffer = Outdir + txtname + "_Buffer.shp"
BuffList.append(Buffer)
uri = "file:///%s?crs=%s&delimiter=%s&xField=%s&yField=%s" % (txt, Coordinate_Reference_System,"\t", "X","Y")
layer1 = QgsVectorLayer(uri, txtname, "delimitedtext")
QgsMapLayerRegistry.instance().addMapLayer(layer1)
processing.runalg('qgis:fieldcalculator', layer1, 'Radius', 0, 10.0, 6.0, True, '"ALT"', Outputshp)
QgsMapLayerRegistry.instance().removeMapLayer(layer1)
processing.runalg("qgis:variabledistancebuffer", Outputshp, 'Radius', 10.0, True, Buffer)
OutputMerge = Outdir + "Merged.shp"
processing.runalg("qgis:mergevectorlayers", BuffList, OutputMerge)
processing.runalg("qgis:dissolve", OutputMerge, True, '', Output_shapefile)
del TXTlist, BuffList, txt