Skip to content
Advertisement

Advance a Interpolation

Note; No special knowledge of Pykrige is needed to answer the question, as I already mention examples in the question!


Hi I would like to use Universal Kriging in my code. For this I have data that is structured as follows:

JavaScript

You can find my data here:https://wetransfer.com/downloads/9c02e4fc1c2da765d5ee9137e6d7df4920220618071144/8f450e

I want to interpolate the data (Latitude, Longitude, Altitude and O18) with Universal Kriging and use the height as a drift function.

So far I have programmed this here but I am not getting anywhere, e.g. I don’t know how to effectively use the height as a drift function and the information from the Pykrige documentation is of limited help:

JavaScript

I now only use universal kriging and create these images:

enter image description here

I get the expected error: ValueError: Must specify location(s) and strength(s) of point drift terms.

I just know that I have to create a grid with the height, but I don’t know how and I don’t know how to make the drift dependent on the altitude. The altitude formula is:

-0.2 (O18)/100 m(altitude)

where 100 m represents 100 m hight difference.

The interesting thing is that there is this website with examples: however, I am too inexperienced in coding to understand the examples and to transfer them to my example: https://python.hotexamples.com/examples/core/-/calc_cR/python-calc_cr-function-examples.html

conclusion: I don’t know how to define the [“external_drift”] to do what I want (this is based on me being so inexperienced in coding in general).

I’ve been trying to solve these problems for 3 weeks now, but I’m really getting nowhere.

Advertisement

Answer

From the documentation of pykrige.uk.UniversalKriging (https://geostat-framework.readthedocs.io/projects/pykrige/en/stable/generated/pykrige.uk.UniversalKriging.html#pykrige.uk.UniversalKriging):

drift_terms (list of strings, optional) – List of drift terms to include in universal kriging. Supported drift terms are currently ‘regional_linear’, ‘point_log’, ‘external_Z’, ‘specified’, and ‘functional’.

In your code you specified drift_terms = [“external_drift”] which is not supported. I’m sorry I don’t have specialized knowledge in this model so I cannot help you much further. But it’s very likely these are the parameters that you need to specify:

external_drift (array_like, optional) – Gridded data used for the external Z scalar drift term. Must be shape (M, N), where M is in the y-direction and N is in the x-direction. Grid spacing does not need to be constant. If grid spacing is not constant, must specify the grid cell sizes. If the problem involves anisotropy, the external drift values are extracted based on the pre-adjusted coordinates (i.e., the original coordinate system).

external_drift_x (array_like, optional) – X-coordinates for gridded external Z-scalar data. Must be shape (M,) or (M, 1), where M is the number of grid cells in the x-direction. The coordinate is treated as the center of the cell.

external_drift_y (array_like, optional) – Y-coordinates for gridded external Z-scalar data. Must be shape (N,) or (N, 1), where N is the number of grid cells in the y-direction. The coordinate is treated as the center of the cell.

User contributions licensed under: CC BY-SA
8 People found this is helpful
Advertisement