# How to use grdproject to get equal grid spacing ( i.e. X\_inc and Y\_inc)

**URL:** <https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114>\
**Category:** Q&A\
**Created:** [November 26, 2019, 6:07am UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114 "2019-11-26T06:07:47Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 26, 2019, 6:07am UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/1 "2019-11-26T06:07:47Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/a288b7bb26c26aa1d4dd98bbd8cedc7c3df85029.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 26, 2019, 2:40pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/2 "2019-11-26T14:40:19Z")

</div>

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`

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 26, 2019, 2:55pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/3 "2019-11-26T14:55:08Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 26, 2019, 2:58pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/4 "2019-11-26T14:58:26Z")

</div>

> [@John](#):
>
> but the surface convert from xyz to grd?

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.

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 26, 2019, 6:01pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/5 "2019-11-26T18:01:37Z")

</div>

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

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/a288b7bb26c26aa1d4dd98bbd8cedc7c3df85029.png)

---

<div class="post-metadata">

**Author:** ![pwessel](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/pwessel/32/30_2.png) [@pwessel](https://forum.generic-mapping-tools.org/u/pwessel)\
**Post date:** [November 26, 2019, 6:20pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/6 "2019-11-26T18:20:59Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 26, 2019, 6:33pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/7 "2019-11-26T18:33:25Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 26, 2019, 8:05pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/8 "2019-11-26T20:05:10Z")

</div>

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.

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 27, 2019, 7:15am UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/9 "2019-11-27T07:15:17Z")

</div>

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.

 ![image](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/7475edac43e94495558e537fe06e5361ec2f1e1f.png)

---

<div class="post-metadata">

**Author:** ![Joaquim](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/joaquim/32/16_2.png) [@Joaquim](https://forum.generic-mapping-tools.org/u/Joaquim)\
**Post date:** [November 27, 2019, 10:57am UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/10 "2019-11-27T10:57:32Z")

</div>

(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.

---

<div class="post-metadata">

**Author:** ![John](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/john/32/40_2.png) [@John](https://forum.generic-mapping-tools.org/u/John)\
**Post date:** [November 27, 2019, 1:12pm UTC](https://forum.generic-mapping-tools.org/t/how-to-use-grdproject-to-get-equal-grid-spacing-i-e-x-inc-and-y-inc/114/11 "2019-11-27T13:12:16Z")

</div>

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