I think I might have made a mistake. It looks like there was a specific section to ask about PyGMT and I didn’t post it there. I’m sorry. I’m kind of dumb and didn’t really notice. I also didn’t really understand your solution so I’ll try to rephrase the question.
I am trying to follow this example: https://www.earthinversion.com/utilities/pygmt-high-resolution-topographic-map-in-python/#importing-libraries up to the part where contour lines are plotted and the only thing I want to change is the data being used. Instead of ‘@earthrelief_30s’, I am trying to change the region (min/max lon and lan) and use data stored in a local .csv file pictured below:
example:
Data: x = longitude / y = latitude / z = elevation
It is my understanding that for grdImage to work, the data has to be in the format netCDF. I have tried to convert my data but after a multitude of failed attempts, I still don’t know how to.
My question is: “How do I turn my .csv data into a format that will in turn output a functioning map.
Thank you for your help.
The rest of the code is the same as that in the example, displayed in the link and in the code below:
import pygmt
minlon, maxlon = -67.025, -67.006 #change 1
minlat, maxlat = 17.963, 17.977 #change 2
Def main():
topo_data = ‘path_to_local_data_file/data.csv’ #change 3/final change
fig = pygmt.Figure()
pygmt.makecpt(
cmap=‘topo’,
series=‘-8000/8000/1000’,
continuous=True
)
fig.grdimage(
grid=topo_data,
region=[minlon, maxlon, minlat, maxlat],
projection=‘M4i’,
shading=True,
frame=True
)
fig.grdcontour(
grid=topo_data,
interval=4000,
annotation=“4000+f6p”,
limit=“-8000/0”,
pen=“a0.15p”
)
fig.colorbar(
frame=‘+l"Topography"’
)
fig.show()
if name == “main”: main()