Hello Plotly Community,
I’m trying to create a hillshade. My data set consist of three columns which are longitude latitude and elevation.
I’ve found an example about this topic
So far i was able to create heatmap version but how can i convert it to hillshade ?
Here’s my example data set;
data
Here’s my code:
import plotly.graph_objects as go
import numpy as np
import scipy.interpolate
x, y, z = np.genfromtxt(r'topo.txt', unpack=True)
N = 250
xi = np.linspace(x.min(), x.max(), N)
yi = np.linspace(y.min(), y.max(), N)
zi = scipy.interpolate.griddata((x, y), z, (xi[None,:], yi[:,None]), method='nearest')
fig= go.Figure(go.Heatmap(x=xi, y=yi, z=zi, colorscale='Earth'))
fig.show()
Update 1
If i use matplotlib lightsource and increase N
import plotly.graph_objects as go
import numpy as np
import scipy.interpolate
from matplotlib.colors import LightSource
x, y, z = np.genfromtxt(r'topo.txt', unpack=True)
N = 750
xi = np.linspace(x.min(), x.max(), N)
yi = np.linspace(y.min(), y.max(), N)
zi = scipy.interpolate.griddata((x, y), z, (xi[None,:], yi[:,None]), method='nearest')
ls = LightSource(azdeg=315, altdeg=45)
hs=ls.hillshade(zi,vert_exag=1)
fig= go.Figure(go.Heatmap(x=xi, y=yi, z=hs,
colorscale='Earth',))
fig.show()
It produces something like hillshade but it looks very bad : (
Heatmap Version
Hillshade Version