# Grdview with pattern fill ends up solid black without pattern

**URL:** <https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173>\
**Category:** Q&A\
**Created:** [January 5, 2021, 8:48am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173 "2021-01-05T08:48:01Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jedokaplan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jedokaplan/32/96_2.png) [@jedokaplan](https://forum.generic-mapping-tools.org/u/jedokaplan)\
**Post date:** [January 5, 2021, 8:48am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/1 "2021-01-05T08:48:02Z")

</div>

Working with GMT 6.1.1 (classic mode)

I am trying to plot a pattern fill as an overlay over another map. To do, this I would use `gmt grdview` with a categorial cpt containing the pattern information. Unfortunately, the result comes out as solid black fill (see image attached), no matter what do to change the pattern fill specification, resolution, etc. Consider the following simplification of my plotting script:

```
#!/bin/bash

module load GMT

cat << END > pattern.cpt
0 p5+r200
END

gmt grdmath -R0/3/0/3 -r -I1 0 = test.nc

gmt psbasemap -R0/3/0/3 -JX3 -B0 -P -K > test.ps

gmt grdview test.nc -R -J -T+s -Cpattern.cpt -O -P >> test.ps

gmt psconvert -A -Tg test.ps
gmt psconvert -A -Tf -Z test.ps

```

The result of this script gives me this image:

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

Does anyone else have this problem?

Thanks, Jed

---

<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 5, 2021, 1:24pm UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/2 "2021-01-05T13:24:52Z")

</div>

I think that your file it has not a format of a (categorical) CPT. Do you see any warning message in the terminal?

```auto
0 p5+r200

```

---

<div class="post-metadata">

**Author:** ![jedokaplan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jedokaplan/32/96_2.png) [@jedokaplan](https://forum.generic-mapping-tools.org/u/jedokaplan)\
**Post date:** [January 5, 2021, 1:39pm UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/3 "2021-01-05T13:39:55Z")

</div>

I do not get any warnings during the script execution. You can also try it with a regular cpt; the behavior is the same.

---

<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 7, 2021, 5:21pm UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/4 "2021-01-07T17:21:53Z")

</div>

The CPT is OK. I try with a regular color and it worked

```auto
cat << END > pattern.cpt
rem	0 red
rem	END

```

 ![test_red_T+s](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/231568d05127856059f12e75bf2a34d1a99351be.png)

I try with the pattern and I get your figure. So I think that it is a **bug**.

I also try with modifying grdview and with this command I get a pattern (but I think it is not what you want):

```
gmt grdview test.nc -R -J -Qs -Cpattern.cpt -O >> test.ps -Vi -JZ1c

```

 ![test](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/b2080abd71325897f9ef2cb702be84835c2dc949.png) ![test_pattern_Qs](https://canada1.discourse-cdn.com/flex047/uploads/gmt/original/1X/59ff5b080b37e0698d030ddf6ecf3469563f2d11.png)

BTW, you could replace these commands:

```auto
gmt psconvert -A -Tg test.ps
gmt psconvert -A -Tf -Z test.ps

```

with this:

```auto
gmt psconvert -A -Tfg -Z test.ps
```

---

<div class="post-metadata">

**Author:** ![jedokaplan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jedokaplan/32/96_2.png) [@jedokaplan](https://forum.generic-mapping-tools.org/u/jedokaplan)\
**Post date:** [January 8, 2021, 1:31am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/5 "2021-01-08T01:31:50Z")

</div>

Thanks for confirming this unexpected behavior @Esteban82. Bug report filed [here](https://github.com/GenericMappingTools/gmt/issues/4630).

---

<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:** [January 8, 2021, 2:31am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/6 "2021-01-08T02:31:13Z")

</div>

Thanks @jedokaplan, now fixed in master.

---

<div class="post-metadata">

**Author:** ![jedokaplan](https://yyz1.discourse-cdn.com/flex047/user_avatar/forum.generic-mapping-tools.org/jedokaplan/32/96_2.png) [@jedokaplan](https://forum.generic-mapping-tools.org/u/jedokaplan)\
**Post date:** [January 13, 2021, 8:20am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/7 "2021-01-13T08:20:40Z")

</div>

I can confirm that the fix for the bug described above is now working properly, however, I still have an issue using `grdview -T+s` when the overlay `.nc` file I want to plot is large. Consider the following simplified example:

```
#!/bin/bash

gmt gmtset GMT_VERBOSE i

cat << END > pattern.cpt
0 p5+r200
END

gmt grdmath -R-180/180/-40/40 -fg -r -I1 0 = test.nc

gmt psbasemap -Rtest.nc -JX20/10 -B0 -P -K > test.ps

gmt grdview test.nc -R -J -T+s -Cpattern.cpt -O -P >> test.ps

gmt psconvert -A -Tf test.ps

```

When I execute this script, the plotting is fast, but gmt hangs on the `psconvert` step. It appears to take a very long time to calculate the map BoundingBox (about 45 seconds) on my machine. The actual conversion step to pdf is faster, although still pretty slow. If I increase the domain of the input `.nc` to, e.g., `-Rd`, `psconvert` takes so long to compute the BoundingBox that I thought the script was hanging, although it appears that it actually isn’t - it takes about 1m30s to calculate the BoundingBox and then another 15s or so to convert to PDF.

Is this the expected behavior and could there be any way to make this process faster? I have been thinking about converting my overlay raster into a polygon for example, but maybe there are other ways.

Thanks,

Jed

---

<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:** [January 14, 2021, 5:11am UTC](https://forum.generic-mapping-tools.org/t/grdview-with-pattern-fill-ends-up-solid-black-without-pattern/1173/8 "2021-01-14T05:11:07Z")

</div>

The slowness is entirely caused by ghostscript. Perhaps the algorithm it is using to deal with patterns is sub-optimal. We can try to submit an issue with ghostscript to see if they can find ways to speed it up.
