# Completing and re-registering a geographic grid

I suspect this has an easy answer, and is probably something I’ve already done (!), but the solution is eluding me. Everything, input/output, is in gridline registration.

The starting oceanic input grid has a 0.2° resolution with -R-180/179.8/-89.8/89.8 bounds (1800x899).

I need to transform it to a grid with 0.25° resolution with -R-179.875/179.875/-89.875/89.875 bounds (1440x720).

So far, I’ve been trying to do this via grdsample, but I can’t seem to get exactly the bounds I need. It comes back with -R-179.875/179.625/-89.625/89.625. I guess grdsample can’t “wrap-around” my input grid to provide longitude 179.875. How can I fix that?

I even tried using surface, which provides the -R needed, but it interpolates values for cells that are located over land (that can be masked), but it also interpolates non-land cells that were missing (invalid) in the original grid.

Summarizing, there are a list of issues regarding a couple of methods I’m attempting to use:

1. How best to extend the grid to the poles and to east-most edge for use in grdsample, or
2. How to create and apply a mask based on the original grid to the grid interpolated by surface?

Or is there some really simple approach that totally escaped me?!

should it not be -R-179.75/179.75/-89.75/89.75 with 0.25 degree resolution and gridline registration? the “.875” decimal part seems off.

Not sure what it “should” be. I need to match this:

``````mn_201810.grd: Gridline node registration used [Geographic grid]
mn_201810.grd: Grid file format: nf = GMT netCDF format (32-bit float), CF-1.7
mn_201810.grd: x_min: -179.875 x_max: 179.875 x_inc: 0.25 (15 min) name: longitude n_columns: 1440
mn_201810.grd: y_min: -89.875 y_max: 89.875 y_inc: 0.25 (15 min) name: latitude n_rows: 720
``````

`grdsample` does not let extrapolate. That is, you cannot go from 179.8 to 179.875

`-R-179.75/179.75/-89.75/89.75` is not global. It misses the poles and one column.

But the longitudes wrap around. How can I trick GMT to treat it that way? In other words, the column for longitude -180 should be the same as +180.

I guess one could dump the original file with grd2xyz, copy the values for the -180 longitudinal column, paste it to the end of the file, while changing the longitude to +180, and finally run that back through xyz2grd & then through grdsample.

I’m not so worried about the missing pole values.

``````-179.875/179.875
``````

is global at 0.25 and grid registration. It’s the same as `-180/180` (same number of columns) and pixel registration. It’s just that you cannot do it with `grdsample`. Can’t follow what are the issues with the `surface` reinterpolation.

Background on the surface interpolation:

The original grid (at 0.2° resolution) has invalid (NaN) values in non-land oceanic Arctic regions.

Surface will interpolate values for every cell of a grid. It’s trivial to mask the land values.

After interpolating with surface, how can the newly interpolated cells be re-set to match (almost) those NaN-valued non-land cells found in the original grid?

Have you tried `surface -M0c`?