Challenges using grdimage

Hello everyone,

I want to convert a grid (JULY_JUNE_2018.zip (273 Bytes) ) to image using grdimage. The grid is very small in size. I have attached the grid information here:

JULY_JUNE_2018.grd: Title: Grid originally in Surfer 7 format
JULY_JUNE_2018.grd: Command:
JULY_JUNE_2018.grd: Remark:
JULY_JUNE_2018.grd: Gridline node registration used [Cartesian grid]
JULY_JUNE_2018.grd: Grid file format: sd = Golden Software Surfer format 7 (64-bit float, read-only)
JULY_JUNE_2018.grd: x_min: 34 x_max: 35 x_inc: 1 name: n_columns: 2
JULY_JUNE_2018.grd: y_min: -8 y_max: -4 y_inc: 1 name: n_rows: 5
JULY_JUNE_2018.grd: z_min: -0.0208080465946 z_max: -0.00538880052983 name: z
JULY_JUNE_2018.grd: scale_factor: 1 add_offset: 0

My aim is to produce something like this (july_june2018.zip (17.8 KB) ) but the output I am obtaining is very different. This is the output (output.zip (40.6 KB) )

Here’s my MWE

set ps=output.ps
set grd=JULY_JUNE_2018.grd
set cpt=a1.cpt
gmt grd2cpt %grd% -Z > %cpt%
gmt grdimage %grd% -JM3i -R33.5/35.5/-8/-3.5 -C%cpt% -K >%ps%
gmt psxy g.txt -JM3i -W -Ba -R33.5/35.5/-8/-3.5 -Baf -O >> %ps%
gmt psconvert %ps% -A -Tg

I am using Windows 7 64-bits and GMT6.0.0 for Windows OS.

Best regards,
Harold P

Hello Harold,

I could get something like your july_june2018.png under linux using:

ps=output04.ps
grd=JULY_JUNE_2018.grd
range=33.5/35.5/-8/-3.5
cpt=a1.cpt
gmt makecpt -Crainbow -T-0.025/-0.005/0.005 -D -Z > $cpt
gmt grd2xyz $grd | gmt surface -R$range -T0.1 -I1e-2 -Goversampling.grd
gmt grdimage oversampling.grd -JM3i -R$range -C$cpt -Ba1f0.5 > $ps
gmt psconvert $ps -A -Tg


You could play with makecpt and surface options to adjust to your needs.

Best regards,
Marcelo

1 Like

Thank you @MarceloBanik, let me work on your solution. Thanks alot

I have one more question @MarceloBanik , consider the image (output04.zip (87.8 KB) ). Is it possible to clip the region outside the boundary and set it to white color like this image (output05.zip (17.5 KB) ). Here is my code

set ps=output04.ps
set grd=JULY_JUNE_2018.grd
set range=33.5/35.5/-8/-3.5
set cpt=a1.cpt
gmt makecpt -Crainbow -T-0.025/-0.005/0.005 -D -Z > %cpt%
gmt grd2xyz %grd% | gmt surface -R%range% -T0.1 -I1e-2 -Goversampling.grd=sf
gmt grdimage oversampling.grd -JM3i -R%range% -C%cpt% -Ba1f0.5 -K > %ps%
REM Boundary
gmt psxy g.txt -JM3i -W -Ba -R%range% -O >> %ps%
gmt psconvert %ps% -A -Tg

Here is the Boundary file (g.zip (32.4 KB) ).

Again, Thanks alot.

you could use psclip to do it, on my linux, with:

ps=output06.ps
grd=JULY_JUNE_2018.grd
range=33.5/35.5/-8/-3.5
cpt=a1.cpt
gmt makecpt -Crainbow -T-0.025/-0.005/0.005 -D -Z > $cpt
gmt grd2xyz $grd | gmt surface -R$range -T0.1 -I1e-2 -Goversampling.grd=sf
gmt psclip g.txt -JM3i -R$range -K > $ps
gmt grdimage oversampling.grd -J -R -C$cpt -K -O >> $ps
gmt psclip -C -K -O >> $ps
gmt psxy g.txt -J -W -Ba -R -O >> $ps
gmt psconvert $ps -A -Tg

that gives me:

Regards,

Marcelo

1 Like

Thanks alot @MarceloBanik for the support