How to get clip path from line?

I’m currently experimenting with “notching out” the grid lines for other items in a map.

Please note how the grid lines are not plotted when crossing coastlines and when crossing labels.

I achieve this effect by plotting the coastline twice:

gmt coast -W11.13p,white
gmt coast -W1.13p,black

First round with a wide white pen for the “notch” and a second time with a black pen for the actual coastline. This gives me a 5 pt wide clear zone around the black coastline.

Similar with the labels in the map:

gmt text cities.txt -F+jLB -DJ2.5p -C5.5p -Gwhite

a white box around the text does the trick.

For easier understanding how it is done I coloured them here orange and green.

All is nice and well if the landmass is white oder a single color (with some clip trickery). But what if I want to fill the land mass with some gridded data (DEM, hill shading, etc) and still maintain the “notch” around the grid lines?

My only (non-working) ideas so far was to use the coastline itself with a given width as a polygon to create a clipping path from.

Do you have some clever tricks up your sleeve to achieve the desired effect? Your thoughts and ideas are very welcome :slight_smile: