# Psclip difficulities

**URL:** <https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977>\
**Category:** Q&A\
**Tags:** psclip\
**Created:** [May 30, 2023, 11:17am UTC](https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977 "2023-05-30T11:17:49Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mostafa99](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mostafa99](https://forum.generic-mapping-tools.org/u/mostafa99)\
**Post date:** [May 30, 2023, 11:17am UTC](https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977/1 "2023-05-30T11:17:49Z")

</div>

I am using GMT 6.4.0 on Windows 11. I am trying to execute the below script

```
------------------------------------
rem xyz2grd FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V
surface FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V
grd2cpt test.grd -Cseis -I -L-0.6/1.3 -S0.01/1.3/0.01 -Qi -D-0.6/1.3 > colors.cpt
rem nearneighbor FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V -S100k
psscale -Ccolors.cpt -Q -D14/4/7/0.5 -B5:Frequency:/:Hz: -K > testmap.ps
grdimage test.grd -Jm0.3i -Ccolors.cpt -P -K -O >> testmap.ps
pscoast -Jm0.3i -R129/146/30/46 -Ba5f0.g0./a5f0.g0.WSen -Df -A1 -W1p -P -V -O -Swhite >> testmap.ps
psclip clip.txt -R129/146/30/46 -Jm0.3i -O -K >> testmap.ps
psconvert -Tg -P -A testmap.ps
-------------------------------------------------
the clip.txt is containing 
130.0 40.0
136.0 40.0
136.0 45.0
130.0 45.0
---------------------------------------

```

but I have the below result without clipping. Could you please help to use the correct options for psclip??

 ![testmap](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/4/44045035277d69f4923cd8dcf665df102e0fa2a7.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:** [May 30, 2023, 12:37pm UTC](https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977/2 "2023-05-30T12:37:06Z")

</div>

You need to lay down the clip path before your image and then turn off clipping at the end. See the documentation

---

<div class="post-metadata">

**Author:** ![mostafa99](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mostafa99](https://forum.generic-mapping-tools.org/u/mostafa99)\
**Post date:** [May 30, 2023, 2:38pm UTC](https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977/3 "2023-05-30T14:38:07Z")

</div>

I used the following script, as you recommend.  
rem xyz2grd FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V  
surface FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V  
grd2cpt test.grd -Cseis -I -L-0.6/1.3 -S0.01/1.3/0.01 -Qi -D-0.6/1.3 \> colors.cpt  
rem nearneighbor FREQ.txt -Gtest.grd -R129/146/30/46 -I1m -V -S100k  
psscale -Ccolors.cpt -Q -D14/4/7/0.5 -B5:Frequency:/:Hz: -K \> testmap.ps  
psclip clip.txt -R129/146/30/46 -Jm0.3i -Ba5f0.g0./a5f0.g0.WSen -A1 -N -K -O -V \>\> testmap.ps  
grdimage test.grd -Jm0.3i -Ccolors.cpt -P -K -O \>\> testmap.ps  
pscoast -Jm0.3i -R -Ba5f0.g0./a5f0.g0.WSen -Df -A1 -W1p -P -V -O -Swhite \>\> testmap.ps  
psconvert -Tg -P -A testmap.ps  
psclip -C -O -R -Jm0.3i -Ba5f0.g0./a5f0.g0.WSen -A1 \>\> testmap.ps

Yes, it works well now, But my problem now is **How to keep the geographic boundaries and only clip the image inside the land??**

Thanks so much for your help, I am really appreciating

 ![testmap](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/2X/d/d232d4b2e0921bca918c1f406a34e0144d61671c.png)

---

<div class="post-metadata">

**Author:** ![mostafa99](https://avatars.discourse-cdn.com/v4/letter/m/8e8cbc/32.png) [@mostafa99](https://forum.generic-mapping-tools.org/u/mostafa99)\
**Post date:** [May 30, 2023, 2:46pm UTC](https://forum.generic-mapping-tools.org/t/psclip-difficulities/3977/4 "2023-05-30T14:46:05Z")

</div>

It is OK now.  
Thanks so much… I put both psclip before and after the image, then pscoast.

So many thanks.
