I am trying to krig soil volumes in 3D using pykrige. I am using ordinary kriging, but once I am done kriging the data, I am not sure how I can write it to an ascii file, Here is my code:
from pykrige.ok3d import OrdinaryKriging3D
from pykrige.uk3d import UniversalKriging3D
import numpy as np
from matplotlib import pyplot as plt
import pandas as pd
import pykrige.kriging_tools as kt
data_in = pd.read_excel("Krig3D_data.xlsx")
data = data_in.to_numpy()
gridx = np.arange(392050, 392250, 5)
gridy = np.arange(5138395, 5138595,5)
gridz = np.arange(0.0, 5, 0.25)
ok3d = OrdinaryKriging3D(
data[:, 0], data[:, 1], data[:, 2], data[:, 3], variogram_model="linear"
)
k3d1, ss3d = ok3d.execute("grid", gridx, gridy, gridz)
I need to export the kriged data in an ascii file so I can visualize it by slices elsewhere.
Thanks!
Sebastian here from the GeoStat-Framework Team. If you want to also save the kriged data by slices (like you want to plot them later), you could add the following lines of code:
Note, that the corresponding z-value is added to the file-name with one decimal place.