Universal Kriging and heatmap speed flow of river section #216
Answered
by
ChironeX1976
ChironeX1976
asked this question in
Q&A
-
Hi, import plotly.graph_objs as go
from plotly.subplots import make_subplots
import numpy as np
from pykrige.uk import UniversalKriging
# x y z values are a cross section of the speed of riverflow
xyz = np.array([[ 2.,0.,0.],[ 1.9, 0.07,0.002], [1.9,0.21,-0.002],[ 1.9,0.28,-0.006],[ 1.9,0.35,0.],[ 1.8,0.066,0.052],
[ 1.8,0.198,0.02 ],[ 1.8,0.264,0.012],[ 1.8,0.33,0.],[ 1.7,0.07,0.138],[ 1.7,0.21,0.11 ],[ 1.7,0.28,0.097],
[ 1.7,0.35,0.], [ 1.6,0.082,0.121], [ 1.6,0.246,0.097],[ 1.6,0.328,0.071],[ 1.6,0.41,0.],[ 1.5,0.084,0.046],
[ 1.5,0.252,0.035],[ 1.5,0.336,0.073],[ 1.5,0.42,0.],[ 1.3, 0.084,0.005],[ 1.3,0.252,0.018],[ 1.3,0.336,0.021],
[ 1.3,0.42,0.],[ 1.1,0.084,0.018],[ 1.1,0.252,-0.002],[ 1.1,0.336,-0.004],[ 1.1,0.42,0.],[ 0.8,0.064,0.012],
[ 0.8,0.192,0.007], [ 0.8,0.256,0.002],[ 0.8,0.32,0. ],[ 0.5,0.05,0.004], [0.5,0.15,-0.002], [ 0.5,0.2,-0.001],
[ 0.5,0.25,0.], [ 0.3,0.04,0.002],[ 0.3,0.16,-0.004], [ 0.3,0.2,0.], [ 0.15,0.,0.]])
x=xyz[:,0]
y=-xyz[:,1]
z=xyz[:,2]
# plot ugly heatmap
# ------------------
fig = make_subplots()
fig.add_trace(go.Heatmap(x=x,y=y, z=z, type='heatmap', colorscale='bluered', zsmooth=False))
fig.show()
fig.add_trace(go.Heatmap(x=x,y=y, z=z, type='heatmap', colorscale='bluered', zsmooth='best'))
fig.show()
# Try to get uglyness better by krigging interpolation
# ----------------------------------------------------
# set kriging grid
# gridx = cross section of river, in small steps of 0.01 m
gridx = np.arange(min(x), max(x)+0.01, 0.01)
# gridy = depth , in small steps of 0.01 meter
gridy = np.arange(0, max(y)+0.01, 0.01)
# create Universal Kriging-object,
UK = UniversalKriging(x,y,z,variogram_model="linear",drift_terms=["regional_linear"])
# calculate Z-values matrix and variance
krigz, ss = UK.execute("grid", gridx, gridy)
# plot interpolated heatmap
# ---the heatmap is right, the technique is wrong---------------
fig = make_subplots()
fig.add_trace(go.Heatmap(x=x,y=y, z=krigz, type='heatmap', colorscale='bluered', zsmooth=False))
fig.show() |
Beta Was this translation helpful? Give feedback.
Answered by
ChironeX1976
Dec 13, 2021
Replies: 1 comment 1 reply
-
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
LSchueler
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I have been studying the tutorials on this website (and others).
I succeeded in producing a plot of the speed in a cross section of a river based on krigging.
It is still wrong in certain points.
How can i force the method to get a value in a certain point?
Should i take another krigging method?
Please, help. It's for the fish in there :-)
ugly heatmap, before krigging:
nicer heatmap, after krigging:
my new code: