# Custom projection

**URL:** <https://forum.generic-mapping-tools.org/t/custom-projection/1872>\
**Category:** PyGMT Q&A\
**Created:** [July 7, 2021, 5:56pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872 "2021-07-07T17:56:16Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ljeonjko](https://avatars.discourse-cdn.com/v4/letter/l/b5ac83/32.png) [@ljeonjko](https://forum.generic-mapping-tools.org/u/ljeonjko)\
**Post date:** [July 7, 2021, 5:56pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/1 "2021-07-07T17:56:17Z")

</div>

Hi!

Is there a way to tweak the projection of `fig.grdimage` or even `fig.coast` so that the data and coastlines align?

Here’s an example of what I wish to fix in the future

 ![chl_a_avg-min](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/a/ab3cae99989197ce7820f117287f6c961631de5d.png)

Thanks

---

<div class="post-metadata">

**Author:** ![PlanetGus](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/planetgus/32/303_2.png) [@PlanetGus](https://forum.generic-mapping-tools.org/u/PlanetGus)\
**Post date:** [July 7, 2021, 6:32pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/2 "2021-07-07T18:32:55Z")

</div>

Hi,

You could “cheat” using -X -Y option to manually shift one plot relative to the other.

---

<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:** [July 7, 2021, 8:23pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/3 "2021-07-07T20:23:02Z")

</div>

The offset is too big to be ignored … or put under the carpet. Better try to find the reason.

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [July 7, 2021, 10:20pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/4 "2021-07-07T22:20:40Z")

</div>

The GSSHG coastline from `fig.coast` isn’t very accurate. You may want to look at the example at [https://docs.generic-mapping-tools.org/6.2/gallery/ex51.html](https://docs.generic-mapping-tools.org/6.2/gallery/ex51.html) on how to use OpenStreetMap coastlines instead (though it is done in GMT).

---

<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:** [July 7, 2021, 10:35pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/5 "2021-07-07T22:35:16Z")

</div>

Datum differences explain offsets up to at most 300-400 m. Not 70 km like in present case.

But different -R used in the grdimage and the coast commands could explain the observed.

---

<div class="post-metadata">

**Author:** ![ljeonjko](https://avatars.discourse-cdn.com/v4/letter/l/b5ac83/32.png) [@ljeonjko](https://forum.generic-mapping-tools.org/u/ljeonjko)\
**Post date:** [July 8, 2021, 6:42am UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/6 "2021-07-08T06:42:24Z")

</div>

```
fig.grdimage(
    grid=ds[1:800,1:1001])
fig.coast(
    shorelines = True,
    frame=True)

```

This is what I used to plot. I can certainly try to shift the plots relative to the other.

I reckon the issue stems from using `xarray.interp` as per suggestion to solve the issue of uneavenly spaced data grid. This data set is created using a `0.05` step. I’ve tried using multiple interpolations with gradually decreasing step to rectify this, but the offset still looks the same.

If there is another way to work around this, perhaps using something other than `fig.grdimage`?

---

<div class="post-metadata">

**Author:** ![weiji14](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/weiji14/32/33_2.png) [@weiji14](https://forum.generic-mapping-tools.org/u/weiji14)\
**Post date:** [July 8, 2021, 11:49pm UTC](https://forum.generic-mapping-tools.org/t/custom-projection/1872/7 "2021-07-08T23:49:00Z")

</div>

This reminds me, it might also be a pixel vs gridline node registration issue? Could you report the output of `ds.gmt.registration` and `ds.gmt.gtype`? The outputs (0/1) are documented at [https://www.pygmt.org/v0.4.0/api/generated/pygmt.GMTDataArrayAccessor.html](https://www.pygmt.org/v0.4.0/api/generated/pygmt.GMTDataArrayAccessor.html). I’m assuming that your data is from an optical satellite which would usually mean that it is pixel registered, but if your grid is gridline registered, there could be some offset involved.

If you’re interested, see also [https://github.com/GenericMappingTools/pygmt/issues/487](https://github.com/GenericMappingTools/pygmt/issues/487) and [https://github.com/GenericMappingTools/pygmt/pull/476](https://github.com/GenericMappingTools/pygmt/pull/476) for a lengthy discussion.
