Can GMT use layer blending?

In e.g. qgis, you can use blending modes, which (may) improve the map substantially. From the mentioned link, it is described as: it essentially multiplies the colour values of your layer or feature with those sitting beneath it, then divides it by 250. The impact of this is that darker areas of the basemap appear much darker, whilst lighter areas are less impacted.

Does gmt do any of this blending behind the scenes, and if not, is it possible to do?

In qgis, you can first make a hillshade/slope of a raster and then apply the blending to the shillshade/slope that is then plotted ‘above’ the original raster.

You mean? :slight_smile:!

Sorry, Git, Github and Linux are making my life an Inferno when the above link doesn’t work, use this alternative one!

Should’ve seen that coming.

I’ll give Julia a shot, I promise @Joaquim. Thanks :slight_smile:

Still though, can this be done with regular gmt as well?

Don’t know. Maybe grdmix can do it. The problem with doing this kind of things with GMT is memory consumption. GMT does all with floats, which multiplies all by a factor of 4. No problem with small images but for big ones it is.

I am not very familiar with the Qgis algorithm. But from this description, I think that you could calculate an slope grid (with grdgradient) and them calculate the shadow grid from it.

Ah, this is the stuff from my old post :slight_smile:

Thanks both for thoughts.

Just thinking loud;

If I want to plot a simple map of an elevation raster, gmt, internally, will translate each z-value (each node) to an rgb-triplet - typically looked up via a cpt. So what gmt ends up plotting, is the rgb-triplets, and not the z-values (is this train of thought correct…?). So if I wanted to to blending, I would have to have the ‘rgb-grid’ available to apply some math to it.

Yep. In the end we are all flat. Screens, papers, etc have no elevation

1 Like

Your Julia link made me think of my old post, which brought me again to this post.

I’m basically trying to do this, multiply (thats the blending mode that gave good results in qgis, that I want to replicate).

This is just grid1 x grid2, so the equation becomes: \
-A slope.tif \
-B knipo.tif \
--allBands=B \
--overwrite \
--calc="uint8( ( (A/255)*(B/255) ) * 255 )" \

Which gives a (to me) almost perfect shading. If only I had somewhere to put this expression in gmt!

Edit: Here A = slope.tif is slope extracted from the grid in qgis and B = knipo.tif is an elevation grid.

GDAL vrt files can probably do this calculation as well. And a vrt should be loadable from GMT (Mirone does it).

Thanks for the suggestion.

I guess gmt has to do the same thing when applying intensities to a plot to create ‘shade effects’. Do you know how it does this? Equation?

Yep, I did a couple of them. It’s code in grdgradient

Thanks @Joaquim, I will take a look.

But the code in grdgradient only deals with making gradients - not applying them…? Isnt that e.g. grdimages job?

grdimage assigns the colors to each cell but the radiances/shadings are computed in grdgradient. The RGB color is converted to HSV where shadings are applied and the result is converted back to RGB. This is a different procedure from that blends images … derived from gradients.

Thanks @Joaquim.

grdgradient.c it is then.

@Joaquim I did test vrt and gmt reads it fine (through gdal I assume).

I tried to look at grdgradient-c, but my C skills are not good enough.

If I run a simple grdimage - is it easy for you to tell me what equation is used to blend in the shade with the RGB’s? Can you refer to one of the blend modes listed here?

Andreas, I know the answer was kind of short, but it was given in my post above. GMT does not use a blending model like those you linked. It computes a brightness between [-1 1] (well, less. gmt.conf has params for it) and adds it to the S channel of colors that have, intermediately, converted to HSV.

1 Like

Thanks again, @Joaquim. Sorry for the confusion.