I need to write an interpolation script for QGIS. I want use TINInterpolation method from Interpolation plugin. I found class in API documentation but I don't know how to write QList object with attributes for interpolation. This is constructor from QGIS API.
QgsTINInterpolator (const QList< LayerData > &inputData, TIN_INTERPOLATION interpolation=Linear, bool showProgressDialog=false)
I cannot find any code snippet only this API documentation - https://qgis.org/api/classQgsTINInterpolator.html#a81c71e2be210a4b082ea807b0626a1bd
and QList documentation from Qt Api - http://doc.qt.io/qt-4.8/qlist.html#details
I tried to find any other code with QList class but I found only QgsVectorLayer and QgsRasterLayer everytime.
In the documentation is not available in Python bindings it means I can't use it with python or what does it mean? Got this from here: https://qgis.org/api/classQgsInterpolator.html
I'll be very glad for any help.
In QgsInterpolator.LayerData I don't understand why interpolationAttribute is integer. It is number of column? In Interpolation qgis plugin it is a name of column. It is just next question for discussion. Still don't know how to crete LayerData structure.
I got this error:
Traceback (most recent call last): File "", line 1, in TypeError: arguments did not match any overloaded call: QgsInterpolator.LayerData(): too many arguments QgsInterpolator.LayerData(QgsInterpolator.LayerData): argument 1 has unexpected type 'int'
when tried this line of code:
lay = QgsInterpolator.LayerData(8, "BREAK_LINES", layer2, True)
I want interpolate vector line data, then use Contour and select only one value from features, this all in script. I started write code to console, but this was first problem which I have. I never use python object programming just procedural. Basics of object programming should I have from Java but I don't understand that documentation. I don't know what means struct reference in python and how should I use it.
layer = QgsVectorLayer(pathToFile, 'test', "ogr") QgsMapLayerRegistry.instance().addMapLayer(layer) ld1 = qgis.analysis.QgsInterpolator.LayerData() ld1.vectorLayer=layer #variable with vector layer ld1.zCoordInterpolation=False ld1.interpolationAttribute=7 #number of column with elevation value ld1.mInputType=2 #BREAK_LINES ...next two layers and LayerData object (ld2 and ld3)... #TIN Interpolation itp=qgis.analysis.QgsTINInterpolator([ld1, ld2, ld3]) rect = layer.extent() res = 10 ncol = int( ( rect.xMaximum() - rect.xMinimum() ) / res ) test = qgis.analysis.QgsGridFileWriter(itp,pathToSave,rect,ncol,ncol,res,res) test.writeFile(False)
Until this part I understand that, but when I start QgsTINInterpolator should take a long time for execution but it is too fast. It is weird...
Next code I don't understand, concretely what is zi variable? (line 693 on github)