Earth Relief maps that only covers the land

Is it possible to plot an Earth Relief based map using grdimage, but only to cover the land? That way, I could put this plot on top of my other plots (such as a filled contour), and it won’t cover any of my contour plots in the ocean.

Many thanks!

Never tried, but maybe grdlandmask? https://docs.generic-mapping-tools.org/dev/grdlandmask.html

1 Like

Leon, you are asking exactly the same questions for gmtmex that you did ask for the Julia wrapper thinking it will be different (easier). But it won’t. At the end they all use GMT and you cannot avoid learning how it works. What the different wrappers offer is a different syntax and the, and this is the huge difference, possibility to access data from a programming environment. You may prefer Matlab to Julia (I often do because of the superior Matlab IDE/debugger) but be warned that the gmtmex syntax is exactly equal to the GMT.jl’s monolithic mode.

You also seem to be wanting to create a complex plot without understanding how image overlays work. If you overlay a black sheet of paper on top of a white one, the only way to see bit of white is if you rip holes in the black sheet. Overlaying images is exactly the same, except tat the holes are made with clip operations (see the GMT modules psclic, grclip, grdmask for fifferent ways of acchiving this result).

It’s silly but I don’t find any link to the GMTMEX paper but you can find it here
https://agupubs.onlinelibrary.wiley.com/doi/10.1002/2016GC006723
please read it and pay special attention to figure 4, which I think may be close to the type of fig you want to create.

Also look at the gmtmex manual to see the CPT structure that lets you access the color values.

1 Like

Thanks for pointing that out, Joaquim. I appreciate all of your help along the way!

Sorry but I find the GMT documentation very hard to follow. There also seems to be a lack of working examples.

It’s great to learn the philosophies, but it is still miles away from the actual execution. As a brand new user, I think the most helpful thing can be a working example. Once I’m able to plot my first map successfully, the rest of the journey can be much smoother.

Based on what you just said, it seems that below is what I need:

  1. First plot a contour, based on my gridded variable (1440 x 720) and its lon and lat ranges using mat2grid. Unfortunately, contourf has not been working for me. Contour is not really an alternative, as what I need is a filled contour.

  2. Then I would need to plot the map using grdimage, and then clip the ocean areas off using one of the clip modules. Unfortunately, have no idea how the clipping works. Googling these modules does not give me any results.

  3. Then I would need to overlay the clipped map image onto my contour. Again I have no idea how this can be executed.

People often confuse this with lacking an example that does exactly what I want. There are tons of GMT examples around.

Nope. If the contours draws exactly on the color transitions you will not see the difference with respect to a filled contour in maps with reasonably high resolution. And sorry, I said previously contour but should be grdcontour

Try reading the docs instead of googling :slight_smile:

A working example in Julia

# Start clip path, clipping water and leaving land
coast(region=:global, clip=:land)

# Plot shaded land
grdimage!("@earth_relief_10m", shade=true)

# end clip path
coast!(clip=:end)

# Start clip path, clipping land and leaving water
coast!(clip=:water)

# create a CPT at exact 1000 m interval to fit the contours
cpt = makecpt(range=(-9000,0,1000));

# Plot ocean area with the above CPT
grdimage!("@earth_relief_10m", cmap=cpt)

# Add contours
grdcontour!("@earth_relief_10m", cont=1000)

# End clip path and display result
coast!(clip=:end, show=1)

@pwessel I think we have a bug in pscoast clipping operations. I had to clip land (-Gc) to show it instead of clipping water (-Sc), and vice-versa.

1 Like

Thank you so much, Joaquim! I can’t express how grateful I am to this example code! It works great.

I’ll also try my best to spend time in reading the documentations.