How to create grid and mask NaN areas with gray color

Hello, Please I need help to convert my data file xyz to grid with grid points NaN masked and output in gray color similar to this figure below. Many thanks.

Hi John,

Here are the GMT modules that can help with your task:

  1. xyz2grd can be used to create a grid from xyz points:
  2. makecpt can be used to make a color palette for your data: Specifically, take a look at the -M option to use COLOR_NAN for the color of NaN values (see for how to set COLOR_NAN).
  3. grdimage can be used to grid the data:
  4. colorbar can be used to make the colorbar:

In addition to the examples at the end of these pages, the general examples page provides some useful examples of these commands in use:

Hope this helps!

Many thanks Sir/Ma, however, xyz2grd will interpolate the data, hence the NaN points will be overlapped after the grid has been generated with xyz2grd. I have tried this

from the photo I shared the NaN grid points are colored in gray representing no data points. while others with data are shown with colors. All I want to do is just to plot my data and how the NaN points to be shown as gray color on my map. Thanks.

Do you try an smaller value for the increment ( xyz2grd -I)?

many thanks, I got it done with grdclip.