# Fig.grdimage transparency and plot UTM

**URL:** <https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690>\
**Category:** PyGMT Q&A\
**Created:** [January 21, 2025, 6:30am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690 "2025-01-21T06:30:22Z")\
**Posts on this page:** 11\
**Page:** 1

<div class="post-metadata">

**Author:** ![rasta.2206](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rasta.2206/32/4686_2.png) [@rasta.2206](https://forum.generic-mapping-tools.org/u/rasta.2206)\
**Post date:** [January 21, 2025, 6:30am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/1 "2025-01-21T06:30:22Z")

</div>

Hi all

I’m recently using PyGMT for my work and i got some issue for plotting raster image (.tiff) file. I got 2 problems here:

1. grdimage didnt work when i used I (shading) and Q (NaN\_transparent). I got this following error : grdimage [ERROR]: Option -Q: Cannot specify a transparent color for grids when intensities are also used  
And when i only used -I the background of the map was colored grey
2. the file used UTM 54N projection and the result when i run the program I got this following error: [“grdview [ERROR]: Map region exceeds 360 degrees”](http://forum.generic-mapping-tools.org/t/grdview-error-map-region-exceeds-360-degrees-when-plotting-data-in-utm-coordinates-with-grdview/4939)

I would greatly appreciate any advice or solutions from the GMT community.

Thanks you

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 21, 2025, 12:24pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/2 "2025-01-21T12:24:29Z")

</div>

Hi @rasta.2206

> [@rasta.2206](#):
>
> grdimage didnt work when i used I (shading) and Q (NaN\_transparent). I got this following error : grdimage [ERROR]: Option -Q: Cannot specify a transparent color for grids when intensities are also used  
> And when i only used -I the background of the map was colored grey

I think this problem was recently fixed ([Grdimage transparency of NAN values](http://forum.generic-mapping-tools.org/t/grdimage-transparency-of-nan-values/5641)). You will have to use the dev version.

For your second problem, I will need to see your script to help you.

---

<div class="post-metadata">

**Author:** ![rasta.2206](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rasta.2206/32/4686_2.png) [@rasta.2206](https://forum.generic-mapping-tools.org/u/rasta.2206)\
**Post date:** [January 22, 2025, 7:49am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/3 "2025-01-22T07:49:11Z")

</div>

Hi @Esteban82 thank for the answer  
Sorry I still dont get it. What do you meant by using the dev version?  
For my second problem this is my code

```auto
import pygmt
trench='D:/00_Pygmt/00_project/01_test/Mariana_PD19MT02_75m_geo.tif'
region = [351487.5, 1066612.5, 1182262.5, 1448587.5]

mariana_trench=pygmt.Figure()

mariana_trench.basemap(
    projection="U52N/15c",
    region=region,
    frame=["WSNE", "xaf", "yaf"], 
    )
mariana_trench.grdimage(
    grid=trench,
    cmap="jet",
    region=region,
    shading=True,)
   
    
mariana_trench.show()

```

Thanks

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 22, 2025, 2:34pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/4 "2025-01-22T14:34:48Z")

</div>

> [@rasta.2206](#):
>
> Sorry I still dont get it. What do you meant by using the dev version?

I meant to that you try to work with the development version of GMT. For that, you have to [build GMT from source](https://github.com/GenericMappingTools/gmt/blob/master/BUILDING.md). What GMT version do you have?

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 22, 2025, 2:41pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/5 "2025-01-22T14:41:25Z")

</div>

> [@rasta.2206](#):
>
> `trench='D:/00_Pygmt/00_project/01_test/Mariana_PD19MT02_75m_geo.tif'`

I suspect that this image is already in UTM coordinates. If so, then, you have to use linear projection to plot the image correctly. Try adding using this instead:

```auto
mariana_trench.grdimage(
    projection=X15c
    grid=trench,
    cmap="jet",
    region=region,
    shading=True,)

```

---

<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:** [January 22, 2025, 8:13pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/6 "2025-01-22T20:13:53Z")

</div>

Posting the example code that errors in pure GMT CLI is **highly** preferable.

---

<div class="post-metadata">

**Author:** ![rasta.2206](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rasta.2206/32/4686_2.png) [@rasta.2206](https://forum.generic-mapping-tools.org/u/rasta.2206)\
**Post date:** [January 23, 2025, 12:52am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/7 "2025-01-23T00:52:53Z")

</div>

I use GMT version 6.5.0  
In development version the -I dan -Q parameters can work in the same time?

---

<div class="post-metadata">

**Author:** ![rasta.2206](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/rasta.2206/32/4686_2.png) [@rasta.2206](https://forum.generic-mapping-tools.org/u/rasta.2206)\
**Post date:** [January 23, 2025, 1:07am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/8 "2025-01-23T01:07:41Z")

</div>

Ok thanks, it worked but the map looked distorted.

This one used plotted using UTM coordinates from the original file that using UTM projection.

 ![Screenshot 2025-01-23 075717](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/2/2e2eead9e188bed6c70ad917ce525fcab07a1f46.png)

And this one plotted using Geographic coordinates. This one I reprojected the image from the original.

 ![Screenshot 2025-01-23 075637](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/8/861d6f729ece7f4641841291eb82de658f39de6e.png)

Thanks

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [January 23, 2025, 2:16pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/9 "2025-01-23T14:16:45Z")

</div>

> [@rasta.2206](#):
>
> the map looked distorted.

This is expected with `projection=X15c`. It sets both vertical and horizontal map size to the same value, 15 cm, regardless of the actual grid dimentions.

---

<div class="post-metadata">

**Author:** ![Esteban82](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/esteban82/32/54_2.png) [@Esteban82](https://forum.generic-mapping-tools.org/u/Esteban82)\
**Post date:** [January 23, 2025, 6:20pm UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/10 "2025-01-23T18:20:53Z")

</div>

> [@mkononets](#):
>
> This is expected with `projection=X15c`. It sets both vertical and horizontal map size to the same value, 15 cm, regardless of the actual grid dimentions.

Yes, I forgot about that. Sorry.

In order to keep the original aspect, try using this command instead:  
`projection=X15c/0`

---

<div class="post-metadata">

**Author:** ![mkononets](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/mkononets/32/4029_2.png) [@mkononets](https://forum.generic-mapping-tools.org/u/mkononets)\
**Post date:** [January 24, 2025, 9:50am UTC](https://forum.generic-mapping-tools.org/t/fig-grdimage-transparency-and-plot-utm/5690/11 "2025-01-24T09:50:53Z")

</div>

No need to be sorry. This gave the topic starter opportunity to learn how `X` projection specification works.
