Paint grid


I want to paint (dry) the zone delineated by a red line , I download the grid from GMT server, but there the grid have negative values, how to face the problem?, using mask, grdlandmask,grdmask or other?



1 Like

You want to fill the polygon?

gmt plot -Gblack .... will do that.

Hello @milton,

Welcome to the GMT forum :slightly_smiling_face:!

I feel the formulation of your question is a bit unclear / misleading.
Is it related to filling the red outlined area (shape) by one single color or do you want to change the elevation values in the area of the Venetian Lagoon to another (positive) value, i.e. manipulate the elevation grid itself?

Hi Yvonne,

Sorry, the red polygon is intended only to highlight the area of interest,
and I want manipulate the elevation grid to positive values near the Venetian Lagoon.
I tried convert to grd to xyz and edit the grid, but it is tedious!!.

Have you an idea?



Hi Milton!

If there the are negative values, then you could make a cpt to plot these values with a color defined by you.

Could you share a simplified version of your script?

Hi Esteban82,

I tried a cpt palette and it do the trick, but i no obtain the same grey scale as using -M option of grdimage (without cpt file).

Here a my script:

gmt gmtset MAP_FRAME_WIDTH 0.15c
gmt gmtset PS_MEDIA A3


Base of Figure

gmt psbasemap “$REG” “$PRJ” -V -K -B1 -B+t"NE Italy Seismicity from 2000 to 2022" > “$OUT”
#gmt grdimage fvg.grd “$PRJ” -Cgeo -I+a -V -O -K >> “$OUT”
#gmt grdimage fvg.grd “$PRJ” -Cven.cpt -I+d -V -O -K >> “$OUT”
gmt grdimage fvg.grd “$PRJ” -M -I+a -V -O -K >> “$OUT”
gmt pscoast “$REG” “$PRJ” -Clightblue+l+r -W0.2p -Dh -N1/0.25p -V -O -K >> “$OUT”
gmt psscale “$REG” “$PRJ” -DJMR+w16c+o1.3/0.5c -Ba10:“Earthquake Depth (Km)”: -Cdpth.cpt -O -V -K >> “$OUT”
gmt pstext “$REG” “$PRJ” -B1 -F+f8p,Times-Italic+cBR+t’’ -Dj6.7/0.1 -O -V -K >> “$OUT”

After i plot the epicenters etc.


Something like this? Here I paint the values below 0 with blue. (I reduce its size to 7.5 cm).

gmt set MAP_FRAME_WIDTH 0.15c
gmt set PS_MEDIA A3


#Base of Figure

gmt psbasemap $REG $PRJ -B1 -B+t"NE Italy Seismicity from 2000 to 2022" -K > $OUT
gmt makecpt -Cgeo -T0/4000 -M > a.cpt

gmt grdimage @earth_relief $PRJ $REG -I+a -Ca.cpt -O -K >> $OUT
gmt pscoast $REG $PRJ -Clightblue+l+r -W0.2p -Dh -N1/0.25p -O >> $OUT

No exactly, i will continue looking for what is the best way,
perhaps grdlandmask…

Like this? Here I just add -Swhite in pscoast.

This is to much better, OK, i will try it.
Thanks a lot,


An alternative idea: Maybe grdfill can help you here?
You can replace a specific (elevation) value in your grid (-N) by a constant value (-Acvalue, here probably a small positive value, e.g., 0.3 m). You have to apply this several times to replace all negative elevation values in the area of the Venetian Lagoon (probably something between -8 m and 0 m). You can save the manipulated grid via -G. Finally, you can plot this grid via grdimage as before. As your study area seems to have no other subregion with such small negative elevation values, this should not affect other parts of the grid.

Hi Yvonne. I think that the tool is grdclip instead of grfill. With the option -Sb.

Yes, you are right @Esteban82, grdclip is definitely the easier way here, instead of applying grdfill multiple times :sweat_smile:. However, I would use -Si instead of -Sb, to be able to give an interval. So, the larger negative elevation values outside the Venetian Lagoon are not affected.

1 Like