Overlay grid on top of another grid - clipping

I want to create a simple map with earth_relief (https://docs.generic-mapping-tools.org/latest/datasets/remote-data.html#global-earth-relief-grids). On top of this, I would like to plot the earth_age (https://docs.generic-mapping-tools.org/latest/datasets/remote-data.html#global-earth-seafloor-crustal-age-grids).

What is the best way to do this? Making a custom clip path? Generate a mask with grdmask?

In simple words, what I want to do:
Take this map, remove all the gray and superimpose it on this (the longitude is shifted, but please ignore that).

If you only worry about the figure, then you should create a clip path.

I just dont know what the best way to create the clippath is. I want to get some ideas before i start manually tracing the earth_age grid.

I think that the gray area are NAN. So with grdimage -Q you could make those nodes transparent. So you just plot first the relief grid and then the age grid with -Q.

That’s a bingo, Esteban82! Thank you, exactly what I was looking for.

Just after I made this clip script… maybe it will be of help to me or others some other time:

#make clip path in other software (e.g. QGIS) and export as shapefile

#convert shapefile to gmt
ogr2ogr -F GMT no_age_clip.gmt no_age_clip.shp &> /dev/null

gmt grdimage -R-5/53/90/81r @earth_relief_05m -JU+34/20c -t50 -K > $ps

#make clip path. everything that is situated inside the polygon defined in no_age_clip.gmt is plotted
gmt psclip no_age_clip.gmt -J -R -K -O >> $ps

#fill the plot slot
gmt grdimage -R -J @earth_age_05m.nc -K -O >> $ps

#end clipping
gmt psclip -C -O >> $ps

#convert ps to png
gmt psconvert -Tg -A -Z $ps

I just make this map with relief and the geological ages based on the age grid.

I use the following batch script (I change the extension from .bat to .txt to uploaded it).
Earth_Relief_Age_CPT-City.txt (1,9 KB)

That’s a fantastic map! Thank you for sharing. Hope it’s OK that I borrow some of your ideas :slight_smile:

1 Like

Yes it is ok. The original idea is yours.