3D terrain graph with colour (as 4th dimension of dataset)

Hello,

Relatively new to Julia and enjoying it a lot! However, I would like to display data that has 4 dimensions, x, y, z (terrain) with a color that is independent of z. For context I’m trying to display geophysics on top of a terrain map. I’ve gone through Makie.jl, PlotlyJS.jl and Plots.jl and can’t quite find anything that suitable.

Do I need to transform my terrain data into an stl file and than overlay it with color using Makie.jl perhaps?

Any ideas to modules to consider would be great!
Thanks

See the GMT.jl module grdview. You want specifically the option drape.

Do you mean something like this?

using GLMakie
using DelimitedFiles


volcano = readdlm(Makie.assetpath("volcano.csv"), ',', Float64)
color = rand(size(volcano)...)

surface(volcano;
    color,
    axis=(type=Axis3, azimuth = pi/4))

1 Like

This is a PlotlyJS example. x,y are artificially added, because my data file contains only information on z.
Your color (the 4th dimension) should be assigned to surfacecolor. Here it is set surfacecolor= z.

using DelimitedFiles, PlotlyJS

z = readdlm("st-helens-before.txt", ' ')
r, c = size(z)
x = 1:c
y = 1:r

fig=Plot([surface(x=x, y=y, z=z, surfacecolor=z, 
        colorscale=colors.gist_earth, colorbar_thickness=25, colorbar_len=0.75
        ), surface(x=x, y=y, z=-1000*ones(size(z)), surfacecolor=z,
                        colorscale=colors.gist_earth,
                        showscale=false)],
Layout(width=500, height=500, font_size=10, scene_camera_eye=attr(x=1.6, y=1.6, z=1)))

St-Helens-before

1 Like

I’ll add this as an example of grdview plus draping an external image.

using GMT

# Get the Gulf of Guinea grid
G = grdcut("@earth_relief_01m", region=(0,10,0,10));

# Drape a photo of a cork tree trunk over it
grdview(G, shade="+nt0.5", proj=:merc, view=(145,35), drape="@wood_texture.jpg",
             zsize=5, surftype=:img, name="texture.jpg", show=true)