pygmt.Figure.coast(shorelines) - how to smooth

I would like to smooth the jagged edges (visible in figure at bottom of page) in the high resolution shorelines produced using pyGMT.

I have attempted to smooth the shorelines by adapting GMT syntax with little success. My code:

fig = pygmt.Figure()
fig.coast(resolution='h', borders=['1/1.5p', '2/0.5p'], shorelines='1/1+s', area_thresh='1000'),
PS_LINE_CAP='round',
PS_LINE_JOIN='round',
fig.show()

Please let me know if you have any suggestions!

Have you try using a lower resolution for the coast data?

Hi @arleaman, as @Esteban82 mentioned, you can try using a lower resolution coastline using the resolution parameter in fig.coast. I.e.:

fig.coast(resolution='c', ...)

where c stands for crude resolution. Refer to https://www.pygmt.org/v0.3.1/api/generated/pygmt.Figure.coast.html.

If you’re interested in using PS_LINE_CAP and PS_LINE_JOIN, you can do so using pygmt.config like so:

with pygmt.config(PS_LINE_CAP="round", PS_LINE_JOIN="round"):
    fig.coast(...)

Hopefully that helps! Feel free to show us your final map if you get it to work :grinning_face_with_smiling_eyes:

1 Like

Thank you @weiji14! Adjusting the config settings worked perfectly!
Screen Shot 2021-06-24 at 2.52.13 PM

1 Like