Hi,
I am trying to plot locations on a 3d map. However, I can’t get the points to stick to the 3d surface. What would be the best way to do this?
Try this. Use a file with the long-lat (or X-Y) of your data. Then use grdtrack to add a 3rd column with the z value from your dem. Finally plot your data with plot3d (or psxyz).
Hi, below is my code. That is sort of what I do, but I think the zsize is somehow messing with everything.
minlon, maxlon = 16.98, 17.16
minlat, maxlat = -22.65, -22.47
grid = pygmt.datasets.load_earth_relief(resolution="01s", region=[minlon, maxlon, minlat, maxlat])
frame = ["xa1f0.25","ya1f0.25", "z2000+lmeters", "wSEnZ"]
pygmt.makecpt(
cmap='earth',
series=f'1400/2300/10',
continuous=True
)
fig = pygmt.Figure()
fig.grdview(
grid=grid,
region=[minlon, maxlon, minlat, maxlat, 1400, 2300],
perspective=[315, 30],
frame=frame,
projection="M15c",
zsize="4c",
surftype="i",
plane="1400+gazure",
shading=-0.1,
# Set the contour pen thickness to "1p"
contourpen="1p",
)
fig.basemap(
perspective=[315, 30],
rose="jTL+w3c+l+o-2c/-1c" # map directional rose at the top left corner
)
# Generate fake coordinates in the range for plotting
lons = minlon + np.random.rand(10) * (maxlon - minlon)
lats = minlat + np.random.rand(10) * (maxlat - minlat)
df = pd.DataFrame()
df['longitude'] = lons
df['latitude'] = lats
track = pygmt.grdtrack(points=df, grid=grid, newcolname="elevation")
fig.plot3d(
x = track.longitude,
y = track.latitude,
z = track.elevation,
style='c0.1i',
color='blue',
pen='black',
label='something',
zsize="4c",
)
