How to plot Latitude Longitude and Elevation in a contour plot

Hi I understand this is very basic but I’m having trouble formatting the file needed to chart. If if have a textile called random.txt with 3 columns with lat long and elevation, how would I chart this in a elevation contour plot with just the basic formatting (will research and change design later)?

gmt xyz2grd random.txt -GrandomN.nc -I1 -Rg
gmt grdimage randomN.nc -Jx10c -Rg -B

Im not sure what area it is so I just used g for global. I tried M for a mercator projection but it said no poles allowed. The program runs but just outputs a gray square. Anything would be appreciated

See the link below for some examples of creating contour plots from table data. Since the first two examples use remote files, you should be able to run them directly to see the output.

Ok thanks! it does work and I am able to graph. However, I want to add some color and make it a color plot. I cant seem to find a option to do that with contour.

You need to provide a colormap (ending in .cpt) to the -C option to do that.

Thank you so much, sorry for more questions but I have made a color map and I’m confused as to why the colors arent showing up inn the output.

I used
gmt makecpt -Cbathy -T-0/100 > colors.cpt

(I wanted to keep the elevation ranges between 1-100)
however when I include -Ccolors.cpt in my contour command it outputs a file, but with no color at all.

gmt contour updated.txt -Wthin -Ccolors.cpt -A2000 -B -pdf map
^^ contour command Im using

thank you for the help!

Please read the section on -W in the contour man page. You will need to use the modifiers to tell GMT taht you want to colors to apply to the lines.