# Problem in grdmask

**URL:** <https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297>\
**Category:** Q&A\
**Created:** [December 3, 2025, 1:23pm UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297 "2025-12-03T13:23:22Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![AdiMoh08](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/adimoh08/32/4155_2.png) [@AdiMoh08](https://forum.generic-mapping-tools.org/u/AdiMoh08)\
**Post date:** [December 3, 2025, 1:23pm UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/1 "2025-12-03T13:23:22Z")

</div>

#!/usr/bin/env sh  
gmt begin aditya1 png

gmt basemap -R73.4/81/28/35 -JM7i -Ba2f2  
gmt grdimage best\_1s.tif -Itopo\_adjust.grd -Cgray99 -E600 -V  
gmt grdmask digitizedpolyjksh.dat -R73.4/81/28/36.7 -I1s -NNaN/1 -Gmask.grd=nb -fg -V  
gmt grdmath resampled\_siteupdate1.grd mask.grd MUL = resampled\_siteupdate1\_masked.grd  
gmt grdmath coupling\_updatedmap.grd mask.grd MUL = coupling\_updatedmap\_masked.grd  
gmt grdimage coupling\_updatedmap\_masked.grd -Ccommon.cpt -E600 -V  
gmt end show  
[digitizedpolyjksh.dat](https://forum.generic-mapping-tools.org/uploads/short-url/lUUmiSNkwFX83xtbRSfDNzzqJO9.dat) (1.1 KB)  
i have uploaded the .dat file. All i want is to remove the polygon or mask it but i dont understand why the polygon is coming like this. please help

 ![aditya1](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/8/8dda12fbb25ff0f678115a97cc12d2f13ea80fc1.jpeg)

---

<div class="post-metadata">

**Author:** ![AdiMoh08](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/adimoh08/32/4155_2.png) [@AdiMoh08](https://forum.generic-mapping-tools.org/u/AdiMoh08)\
**Post date:** [December 4, 2025, 10:49am UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/2 "2025-12-04T10:49:17Z")

</div>

still not able to get

 ![aditya2](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/e/e93483c4e90d5b1212950ffcdde4afcddd6721c8.jpeg)

---

<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:** [December 4, 2025, 2:03pm UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/3 "2025-12-04T14:03:08Z")

</div>

The image you posted first cannot have been produced by your script (that **should have been** wrapped in triple back ticks ``` to facilitate reading) that has no calls to `text` or `velo`). So, I don’t even understand what the problem is.

---

<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:** [December 5, 2025, 10:11am UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/4 "2025-12-05T10:11:02Z")

</div>

So far it appears the topic starter wasn’t the one who wrote the code, and the code wasn’t the one that produced the plot.

I think this is a really difficult situation.

---

<div class="post-metadata">

**Author:** ![AdiMoh08](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/adimoh08/32/4155_2.png) [@AdiMoh08](https://forum.generic-mapping-tools.org/u/AdiMoh08)\
**Post date:** [December 5, 2025, 10:44am UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/5 "2025-12-05T10:44:10Z")

</div>

#!/usr/bin/env sh  
gmt begin test png  
gmt basemap -R73.4/81/28/35 -JM7i -Ba2f2  
gmt grdgradient best\_1s.tif -A135 -Ne0.8+o0.04+a0.05 -Gtopo\_adjust.grd -V  
gmt grdimage best\_1s.tif -Itopo\_adjust.grd -Cgray99 -E600 -V  
gmt grdmask digitizedpolyjksh.dat -R73.4/81/28/36.7 -I1s -N1/0/NaN -Gmask.grd=nb -fg -V  
gmt grdmath resampled\_siteupdate1.grd mask.grd MUL = resampled\_siteupdate1\_masked.grd  
gmt grdmath coupling\_updatedmap.grd mask.grd MUL = coupling\_updatedmap\_masked.grd  
gmt grdimage resampled\_siteupdate1.grd -R73.4/81/28/35 -Icoupling\_updatedmap.grd -Ccommon.cpt -E600 -Q -V  
gmt end show  
sorry for the confusion but this is the script for recent figure uploaded.

---

<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:** [December 5, 2025, 10:57am UTC](https://forum.generic-mapping-tools.org/t/problem-in-grdmask/6297/6 "2025-12-05T10:57:32Z")

</div>

> [@AdiMoh08](#):
>
> ```auto
> gmt grdmask digitizedpolyjksh.dat -R73.4/81/28/36.7 -I1s -N1/0/NaN -Gmask.grd=nb -fg -V
> 
> ```

the above line created mask. If you don’t want the mask, you don’t need that code line.

> [@AdiMoh08](#):
>
> ```auto
> gmt grdmath resampled_siteupdate1.grd mask.grd MUL = resampled_siteupdate1_masked.grd
> gmt grdmath coupling_updatedmap.grd mask.grd MUL = coupling_updatedmap_masked.grd
> 
> ```

the above code lines applied the mask to the `resampled_siteupdate1.grd` and `coupling_updatedmap.grd`  
if you don’t want to do masking, don’t run these `gmt math` code lines.

NB In those `gmt math` code lines that apply the mask both source and destination file names are identical. Every time these lines are executed, the resulting masked grids overwrite the source non-masked files. If you want to do masking and to keep the source grids, give the output files different names.
