Trying to set the power coefficient for the IDW interpolation in QGIS 3.10 in pyqgis.
Whatever number I set it has no effect on the interpolation output - always the same output. The default is 2 but I tried 10, 90, 0.5 and all the same result:
Here's the code:
## Get the selected features by ID first and create a clone layer with that selection
it = [f for f in layObj.getFeatures()]
ids = [5,6,7,8,9,10,12,21,24,26,28] # example of ids only- in reality it's hundreds
layObj.selectByIds(ids)
clone = processing.run("native:saveselectedfeatures", {'INPUT': layObj, 'OUTPUT': memory:{}'.format(layObj.name())})['OUTPUT']
layer_data = QgsInterpolator.LayerData()
layer_data.source = clone
layer_data.zCoordInterpolation=False
layer_data.interpolationAttribute = 'PM10_Emissions_tpa'
# I've tried all of these
layer_data.distanceCoefficient = 10 # https://qgis.org/pyqgis/3.10/analysis/QgsIDWInterpolator.html?highlight=idw#
layer_data.setDistanceCoefficient = 10
layer_data.coefficient = 10
layer_data.mInputType = 1 # I've tried 0 and 1- same exact output
idw_interpolator = QgsIDWInterpolator([layer_data])
export_path = rasOut
rect = clone.extent()
res = pixSizeP
ncols = int( ( rect.xMaximum() - rect.xMinimum() ) / res )
nrows = int( (rect.yMaximum() - rect.yMinimum() ) / res)
output = QgsGridFileWriter(idw_interpolator,export_path,rect,ncols,nrows)
output.writeFile()
Perhaps doing something stupid but can't seem to find a good example that works for me- seen other posts but didn't solve it for me. Can anyone help?