How to convert Zdata to grid data

Hello Professors and dear seniors, I have an issue about converting Z data to grid data. Although I have tried this by myself but I didn’t get it using this script
gmt xyz2grd gb.xyz -D+xdegree+ydegree+zkm -Gmoho.grd -R15/125/-70/33 -I1 -ZTLa.
I am seeking correction or help on how to achieve this conversion from Z data to grid data.
Many thanks.

Have a try with this
gmt blockmean gb.xyz -V -R15/125/-70/33 -I1 | gmt surface -Gmoho.grd -R15/125/-70/33 -I1 -V

many thanks , tried it but didn’t work

Can you confirm the content of the file gb.xyz?

Here is a sample of the Z values
image

here is the script you sent me,

to produce a grid file, you require x, y and z components. I assume that what you have in your file currently is only the z-component. You may need to supply the x- and y-.

the code that generated this result only produced Z values as output file.

yes I know about the one with x ,y and z components, but my issue is the code generated only one output which is Z values, hence there is a need to transform it to xyz component to generate a grid file

See gmt xyz2grd -Z option and append suitable flags, plus give -R -I.