4

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.

1

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 Apr 25 '16 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 Apr 25 '16 at 19:47
  • I am afraid this is beyond my abilities... I guess I will have to do it by hand =) – Nausi Apr 26 '16 at 8:41
0

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!

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.