GRDCUT - Defining the Subregion by Node Values

I’m using GRDCUT (GMT 6.4) to extract elevation data from @earth_relief. I’m only interested in elevations above 2000m, so I want to limit the new grid to nodes with values above that value. I can’t find an argument setting in GRDCUT that allows me to do this. What am I missing?

I thought I might have to use another GMT Module to remove nodes with values below 2000, but if there is, I haven’t found it. Is what I am trying to do even possible? Is the problem that an xy grid has to have (x times y) nodes and so nodes can’t be removed?

See grdclip and set values outside your range of interest to NaN or something.

Yes, the GMT grid files have rectangular shapes. You can set some of the grid points to the “no data” value that is normally NaN in GMT, using grdclip. The grdclip program does not remove the nodes from the grid, but it does mark them so that they won’t be plotted or used for statistical calculations. If you want to work with the data as a set of points instead of a regular rectangular grid, then you can use grd2xyz to convert it.

Thanks Paul & EJ. Yes, I have converted the points I am not interested in to NaN. I’ve also used grd2txt to convert to a text file for a spreadsheet analysis. That’s where my problem lies. I’m examining a 1°x1° grid at 3" resolution. That generates in excess of 1.44 million data points, which is too large to open in a spreadsheet. I can work around the problem by either reducing the resolution to 15" (undesirable) or extracting two separate smaller grids, then combining the two after the unwanted NaN nodes are removed in the spreadsheet. I was hoping that I could streamline the process within gmt, particularly in the grd2xyz module. I imagine the ASCII xyz output wouldn’t have the rectangular grid restriction that a netCDF grid file has.

grd2xyz has option -s that allows suppressing output of data records whose z -value(s) equal NaN.

Thanks mkononets, that’s exactly what I was after. I can’t believe I’ve missed that in the documentation, I must have read through grd2xyz at least a dozen times! The phrase ‘Looking but not Seeing’ comes to mind. Thanks again.

There are some tools (in GMT and in bash) that might help (instead of a spreadsheet).

If you tell us what you are really trying to achieve then perhaps we can be more helpful.