How to use grdproject to get equal grid spacing ( i.e. X_inc and Y_inc)

Hello Professors, I tried to use grdproject to project my geographic data unto a rectangular grid using 20km grid spacing in GMT but my new grid spacing for both X and Y ( x_inc and y_inc) are not the same, because I expect to see both having 20 as new grid spacing, not 19.93 for x_inc and 20.03 for y_inc. How can I resolve this to have equal grid spacing for both axis?, attached is a photo to explain better.

gmt grdproject boug.grd -Gboug2m.grd -R90/110/-20/0 -Jm100/-10/1:1 -Fk -D20

where boug.grd is my bouguer grid data
boug2m.grd is my output data
-R90/110/-20/0 is my longitude and latitude
-Jm100/-10/1:1 is Mercator projection, central meridian and central latitude and scale is 1:1
-Fk is for conversion to kilometers and
-D20 is my new grid spacing

The option -D in grdproject works like option -I of surface but displays much less details in the man page. Please consult the -I in surface man page and think of it as if it was -D of grdproject

Many thanks, but the surface convert from xyz to grd?
I want to first project with 20 km grid spacing then convert to xyz for the work I want to use it for.

Please be more specific. We were talking about grdproject and now all of a sudden you jumped to surface. Sorry but I don’t understand the question.

Hello prof, you mentioned surface so I think you were talking about GMT surface in your first reply to my question, then I reacted to it that GMT surface is different. My main problem is still the very question I asked before your first reply, which is how to resolve the X_inc and Y_inc so that both can have equal grid spacing since that is what I want my new output grid to be and how to make the X_max and Y_max become whole number without a decimal place. In the picture, I expected to see X_inc and Y_inc be 20 each since I applied 20km grid spacing and also to see the X_max and Y_max to be whole number without a decimal place.
Many thanks


Your region in degrees and the projection is not going to yield a xmin/xmax that is in multiples of 20 km. Perhaps this is a limitation of grdproject that we need to address with a new option. What I think happens is that the projeted region is determined (2192x2224 km) and then your stated increment of 20 does not fit so it is adjusted to fit rather than the output region is adjusted to fit the increment.

Yes sir. Many thanks Professor, I tried severally with different flag component but I couldn’t help it that why I raised the question in this forum, my senior colleague also said that it is GMT problem. So no other way than to use it this way? then I will have to assume 20 km for both axis in my software. Am so grateful sir Prof. @ Pwessel Prof. @ Joaquim and others.

I mentioned surface as an example of where you could see the full description of the increment option (-I in surface and -D in grdproject), but I’ve not actually checked that the +e flag would solve your issue. If it doesn’t, and you really want 20.0 km I see no other way then take the output of grdproject and use grdsample to force an exact increment.

I have tried to resample my projected data, still the X_inc and Y_inc are not equal. I guess this is a general GMT issue.
Many thanks for your answers, am grateful.

(2192 - 0) / 20 = 109.6
Your grid limits are not (closely) divisible by 20 so you cannot obtain that. You have to select -R limits such that they are divisible by an integer number of 20 increments.

ok Sir, many thanks. I will consider your suggestion .