Grdcontour plots NaN areas at map border


I try to plot Topo information on a map, but don’t get it working at the map border. To reduce filesize, I resample the ETOPO1_Ice_g_gmt4.grd with
gmt grdsample ./ETOPO1_Ice_g_gmt4.grd -GreducedTopo.grd -I30m

Then I add the topo information to the map by:
gmt grdcontour reducedTopo.grd
-Ctmp_elevation.cpt \ ← tmp_elevation appended at the end of this entry
-J -R \ ← gmt.history at the end of entry for -J and -R values
-K -O \

The result is a map, that has black polygons along the map border. The polygon size is proportional to the amount of resampling.

Do you have any clue, how to remove the NaN / black areas?

Thank you very much for this fantastic toolset!

Oliver Matz

— tmp_elevation.cpt —
0 white 609.6 white
609.6 gray98 1219.2 gray98
1219.2 gray96 1828.8 gray96
1828.8 gray94 2438.4 gray94
2438.4 gray92 3048 gray92
3048 gray90 3657.6 gray90
3657.6 gray88 4267.2 gray88
4267.2 gray86 4876.8 gray86
4876.8 gray84 5486.4 gray84
5486.4 gray82 6096 gray82
6096 gray80 6705.6 gray80
6705.6 gray78 7315.2 gray78
7315.2 gray76 7924.8 gray76
7924.8 gray74 8534.4 gray74
B white
F gray86
N black

— gmt.history —
gmt 6 Session common arguments shelf
JL L87.7/35.4/20.3/20.3/28.7c
R 67.4/20.3/114.01053247/46.3454238635r
@L 8

I am happy to see you are using the Lambert Conic projection for plotting Tibet. This is my favorite projection for this area.

One way to solve this is to use the grdproject command to project the topography into a new grid in the Lambert projection before doing the contours if you want to clip the map to an exact area in the Lambert projection.

It helps a lot if you post something we can run.

Thank you for your feedback.
I will try the approach with grdproject and let you know my success (or fail). Future posts or questions will contain something to run. Thanks Joaquim, sounds like this makes things a lot easier for people who want to help - and if I look for support, I should make it as easy as possible to get help…