0

I wanted to call the interpolation plugin for IDW from python plugin and displays its output on QGIS desktop.

I am able to call the function but the output displayed on QGIS qgis desktop with NAN NAN values.

Below are the lines which I have used to generate the output. OS:UBUNTU

import qgis.core
import qgis.analysis
layer = qgis.utils.iface.activeLayer()

layer_data = qgis.analysis.QgsInterpolator.LayerData()

layer_data.vectorLayer = layer
layer_data.zCoordInterpolation=False 
layer_data.InterpolationAttribute = 10 #attribute index starting from 0
layer_data.mInputType = 1

tin_interpolator = qgis.analysis.QgsIDWInterpolator([layer_data])

export_path ="/home/usr/Documents/After Krigging/2.asc"
rect = layer.extent()
output = qgis.analysis.QgsGridFileWriter(tin_interpolator,export_path,rect,300, 300, 1015.33333,728.66667)
output.writeFile(True)  

iface.addRasterLayer(export_path, "interpolation_output")

The image below is the output I got after running the above lines. Can Anyone suggest me what I should do to solve this problem?

Output

It generate the file 1.asc but it have all values as -9999 which is incorrect, can anyone suggest what I need to change in the function call to make sure this kind of data is not generated.

0

The class definition later got changed. Just change the layer_data.InterpolationAttribute = 10 to layer_data.interpolationAttribute = 10 it will work. Changing "I" to "i".

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.