I would like to use interpolate point data to create a raster in QGIS. I am doing batch analysis so I would like to use a python script.
I found this question : how-to-add-an-interpolation-raster-from-the-python-console-in-qgis and related "answer" QGIS user manual.
I thus tried to get the QgsInterpolator
function to work. But I could not find how to use it, nor is it present in the processing.alglist()
.
This question how-to-call-the-interpolation-plugin-from-the-python-console also provide some elements, but I could not find which parameters to enter for the RasterInterpolator
.
2 Answers 2
Are you using the RasterInterpolator plugin, or the core plugin (which appears as InterpolationPlugin
in the plugins manager)?
The core plugin doesn't seem to have a python wrapper (the same goes for Georeferencing plugin).
3rd party plugins don't appear in the algorithms list, nor do they appear in the Processing toolkit (it would be awesome if they did...)
The code in the accepted answer to the second linked question looks promising. You'll need to have installed RasterInterpolator plugin. Try pasting it into the Python Console
.
If you're trying this from a standalone script, you'll have the extra complexity of setting up the python path yourself.
If it is RasterInterpolator, the source code on github will probably help with the parameters you need.
-
From what I understand of the second linked question and from the RasterInterpolator code, this plugin allows to interpolate data for 1 point when you have a raster layer. I would like to create a raster from points...Nausi– Nausi2016年04月25日 07:24:05 +00:00Commented Apr 25, 2016 at 7:24
-
ah, ok. A similar question was asked on the mailing list about the Georeferencing core plugin, which suggests that if you know how to use SIP (and find the appropriate source code for the plugin) you could write your own wrapper to allow python to call the underlying C++ code.Steven Kay– Steven Kay2016年04月25日 19:47:09 +00:00Commented Apr 25, 2016 at 19:47
-
I am afraid this is beyond my abilities... I guess I will have to do it by hand =)Nausi– Nausi2016年04月26日 08:41:53 +00:00Commented Apr 26, 2016 at 8:41
If a solution to your question is still relevant, I suggest you take a look at the updated answers of the questions you refer to. I was able to provide a solution to your problem, you can find them at the following two questions:
How to compute an interpolation raster from the python console in QGIS
How to call the interpolation plugin from the python console?
This solution is based on the usage of the QGIS interpolation classes (QgsInterpolator
, QgsTINInterpolator
, QgsIDWInterpolator
, QgsGridFileWriter
) in a short python script. I hope it poses an easy solution for you!