3

I am trying to do kriging on mortality rates using QGIS (I have version 3.0 but I downloaded the 2.18.20 to be able to follow the web documentation and most of the answers here).

From what I have understood, before running kriging it is necessary to run a variogram model to get the estimated model. I know both variogram and kriging can be run in QGIS using SAGA tools and that is what I am trying to do.

However, most of the "tutorial" I found online provide an empirical variogram graph (y-axis, semivariogram and x-axis, distance) that I am not able to draw with any command on QGIS.

Should I run this part of the analyisi in R as most of the people do or there is a way to do the same staying in QGIS?

3
  • I agree with you. From QGIS processing toolbox only Variogram cloud is available and it is a little bit hard to build variogram model from there. Most people would do it in R, but I recommend SAGA 6.3 which has fascinating interactive tool Variogram (Dialog).
    – Kazuhito
    Commented Jun 20, 2018 at 9:41
  • @Kazuhito Thank you. It is really useful indeed. And can I run kriging directly in SAGA or is it better to go back to QGIS?
    – PostDocing
    Commented Jun 20, 2018 at 12:23
  • 1
    I personally prefer SAGA and export the output (GeoTiff) to QGIS. Some parameters in QGIS processing GUI is not intuitive. Once you learn the whole process in SAGA, it is easy doing the same in QGIS.
    – Kazuhito
    Commented Jun 20, 2018 at 13:10

1 Answer 1

1

If you know how to program in R, you can do a R script for QGIS, there is some minor perks you need to do, but for that matter, SHP files can be understood as S4 type data, and you can build the script in R and then adapt the inputs and outputs in QGIS R console, or you can do the core script and then integrate in QGIS.

In order to make the variograms, you can use the variogram() function to build the cloud and empirical variograms, and the fit.variogram() function to fit your model into an specific covariance function in order to obtain the theoretical variogram, both are part of the gstat package.

The variogram() function have an "alpha" argument where you can also model anisotropy by providing a vector with the angles, and also a "width" argument where you can provide the LAG distance. All this can be printed in the console results by adding ">" in the lines than you need to feed to the console.

For graphical results you can use the plot() function from core R or ggplot() from the ggplot2 package, both are compatible and usable in R QGIS console, but take into account than the tool can only provide inside QGIS the last plot, if you want several of them, then you need to use ggsave() and provide a work directory to save into.

You can check an code example in here: QGIS/Rscripts/Variogram modeling

And you can look for console input/output calls in here: R Syntax Summary table for Processing (yeah, the QGIS versión is outdated, but the processing calls are still in use, and most of them are valid).

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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