Introduction

The gstlearn R package is a cross-platform R package wrapping the gstlearn C++ Library. It offers to R users all famous Geostatistical methodologies developed and/or invented by the Geostatistic Team of the Geosciences Research Center! It is the successor of the RGeostats R package.

To install the gstlearn R Package, you need R 4.2 (or higher). You can then execute the following R command:

# Uncomment next line for installing last release of gstlearn package (remove '#' character) 
#install.packages("gstlearn",repos="https://soft.mines-paristech.fr/cran")

Loading the package

library(gstlearn)
library(ggplot2)
library(ggnewscale)

Calling the next function (acknowledge_gstlearn) at startup is a good practice in order to check the version of gstlearn you are currently running:

#acknowledge_gstlearn()

First code: Create and display a database

We create a regular 2-D grid and simulate a variable using a geostatistical Model

db = DbGrid_create(nx=c(100,100))
model = Model_createFromParam(type = ECov_CUBIC(), range = 30)
err = simtub(NULL, db, model, nbtuba=1000)

The simulated result is plotted

p = ggDefaultGeographic()
p = p + plot.grid(db)
p = p + plot.decoration(title="Check is successful!")
ggPrint(p)